How to retrieve XMPP user information - objective-c

I need to retrieve user information saved on openfire server.
XMPPvCardCoreDataStorage* xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
XMPPvCardTempModule* m = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage];
[m fetchvCardTempForJID:[sender myJID]];
How/where I can read result of request? Is the right way to "query" openfire server?
I also tryed:
XMPPIQ *iq = [[XMPPIQ alloc] initWithType:#"get"];
[iq addAttributeWithName:#"id" stringValue:#"v1"];
[iq addAttributeWithName:#"from" stringValue:[NSString stringWithFormat:#"%#", sender]];
[iq addAttributeWithName:#"type" stringValue:#"get"];
DDXMLElement *query = [DDXMLElement elementWithName:#"vCard" xmlns:#"vcard-temp"];
[iq addChild:query];
[_xmppStream sendElement:iq];
Where sender is XMPPJID of the searched user.
XMPPIQ is successfully sended and debugger enter in method:
- (XMPPIQ *)xmppStream:(XMPPStream *)sender willReceiveIQ:(XMPPIQ *)iq;
If I print iq I've:
<iq xmlns="jabber:client" type="result" id="v1" to=<MYJID> >
<vCard xmlns="vcard-temp"/>
</iq>

Related

EKRecurrenceRule not saved with EKEvent

I have an app running, wich worked just fine until iOS11. Among many other things, it sets up EKEvents with recurrence. Those events still copy to the calendar as expected, but without the recurrence. And the recurrence vanishes after saving the event.
Thats how I'm doing it:
EKEventStore *newStore = [[EKEventStore alloc] init];
// define new EKEvent
EKEvent *newEvent = [EKEvent eventWithEventStore:newStore];
newEvent.calendar = [ResourceManager sharedResourceManager].selectedCalendar;
newEvent.allDay = TRUE;
newEvent.startDate = loopNSDate;
newEvent.endDate = loopNSDate;
newEvent.availability = EKEventAvailabilityFree;
EKRecurrenceRule *rule = [[EKRecurrenceRule alloc]
initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily
interval:diensteInPlan
end:end];
NSArray *recurrenceRulesForDate = #[rule];
newEvent.recurrenceRules = recurrenceRulesForDate;
newEvent.title = #"EventTitle";
newEvent.notes = note;
NSError *error = nil;
[newStore saveEvent:newEvent span:EKSpanThisEvent error:&error];
NSLOGging the newEvent before "saveEvent..." shows an event with the correct recurrence. But NSLogging it afterwards shows the same event - but with (nill) as recurrence.
Am I missing something here? Many thanks in advance.

Google Drive API for Objective-C return some file not all

I'm implementing Google Drive Api for my mac application using Google API Client for REST Library below,
- (void)fetchFileList {
_fileList = nil;
_fileListFetchError = nil;
GTLRDriveService *service = self.service;
GTLRDriveQuery_FilesList *query = [GTLRDriveQuery_FilesList query];
// Because GTLRDrive_FileList is derived from GTLCollectionObject and the service
// property shouldFetchNextPages is enabled, this may do multiple fetches to
// retrieve all items in the file list.
query.fields = #"kind,nextPageToken,files(mimeType,id,kind,name,webViewLink,thumbnailLink,trashed)";
_fileListTicket = [service executeQuery:query
completionHandler:^(GTLRServiceTicket *callbackTicket,
GTLRDrive_FileList *fileList,
NSError *callbackError) {
// Callback
_fileList = fileList;
_fileListFetchError = callbackError;
_fileListTicket = nil;
NSLog(#"%#", fileList);
}];
}
Here the return value
GTLRDrive_FileList 0x6080002404e0: {kind:"drive#fileList" files:[5]}
There are 7 items on my drive but it returns only 5 items?
It may have something to do with your nextPageToken. It returned only the result of a certain page, not all of them.
Check this docs:
Sometimes a query may return a large number of results, which are
returned one page at a time. When a result object includes a
nextPageToken string, you can execute the query again; supply the
returned token as the pageToken property of the new query, fetching
the next set of results. You can repeat this until you reach the last
page, which will not inlude a nextPageToken string.
GTLServiceDrive *drive = ...;
GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = search;
[drive executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFileList *fileList,
NSError *error) {
if (error == nil) {
NSLog(#"Have results");
// Iterate over fileList.files array
} else {
NSLog(#"An error occurred: %#", error);
}
}];
Try the Drive sample from the iOS Quickstart on how to fetch Files properly. Here's a snippet:
/ Construct a query to get names and IDs of 10 files using the Google Drive API.
- (void)fetchFiles {
self.output.text = #"Getting files...";
GTLQueryDrive *query =
[GTLQueryDrive queryForFilesList];
query.pageSize = 10;
query.fields = #"nextPageToken, files(id, name)";
[self.service executeQuery:query
delegate:self
didFinishSelector:#selector(displayResultWithTicket:finishedWithObject:error:)];
}

Need assistance regarding using the xep-0184

I am using robbiehanson/XMPPFramework for my current project, I can send and receive messages to people in my roster, but now I have to implement message delivery status. I know the xep its 0184 and I have also included in my project, I am having difficulty utilizing it.
I read in xep-0184 document that request element must also included in message, so here is my code:
#import "XMPPMessage+XEP_0184.h"
.
.
.
NSXMLElement *body = [NSXMLElement elementWithName:#"body"];
[body setStringValue:messageStr];
NSXMLElement *request = [NSXMLElement elementWithName:#"request" xmlns:#"urn:xmpp:receipts"];
NSXMLElement *message = [NSXMLElement elementWithName:#"message"];
[message addAttributeWithName:#"type" stringValue:#"chat"];
[message addAttributeWithName:#"to" stringValue:[defaults objectForKey:#"chatWith"]];
[message addChild:body];
[message addChild:request];
.
.
.
XMPPMessage *xm = [[XMPPMessage alloc]init];
NSLog(#"..1..%d",[xm hasReceiptRequest]); // Result = 0
NSLog(#"..2..%d",[xm hasReceiptResponse]); // Result = 0
NSLog(#"..3..%#",[xm extractReceiptResponseID]); // Result = (null)
NSLog(#"..4..%#",[xm generateReceiptResponse]); // Result = <message><received xmlns="urn:xmpp:receipts"></received></message>
Please help how do i get a message delivery status.
I think you forgot to add the module itself.
When you want to add an XMPPModule like XMPPMessageDeliveryReceipts you should add it to the XMPPStream object first, then you can use its functions.
Do the following:
// Setup Message Delivery Recipts Object
XMPPMessageDeliveryReceipts* xmppMessageDeliveryRecipts = [[XMPPMessageDeliveryReceipts alloc] initWithDispatchQueue:dispatch_get_main_queue()];
xmppMessageDeliveryRecipts.autoSendMessageDeliveryReceipts = YES;
xmppMessageDeliveryRecipts.autoSendMessageDeliveryRequests = YES;
[xmppMessageDeliveryRecipts activate:xmppStream];
When xmppStream is your main XMPPFramework object.
Hope i helped.

send message API error

I am sending send message request with XML bodyfrom my iphone application
<mailbox-item><recipients><recipient><person path='/people/93619553' /></recipient><recipient><person path='/people/116008244' /></recipient><recipient><person path='/people/96885725' /></recipient></recipients><subject>Message from butterfli</subject><body>Aasd</body></mailbox-item>
But getting this error
++ LinkedIn engine reports failure for connection 3CD3052A-7061-4EA0-8863-5584270B9177
The operation couldn’t be completed. (HTTP error 404.)
Code is
- (RDLinkedInConnectionID *)sendMessage:(NSDictionary *)shareDict {
NSURL* url = [NSURL URLWithString:[kAPIBaseURL stringByAppendingString:#"/v1/people/~/mailbox"]];
NSString *xmlStr = #"<mailbox-item><recipients>";
NSArray *toIdArray = [[shareDict objectForKey:#"privacy"] componentsSeparatedByString:#","];
for (int l=0; l<[toIdArray count]; l++) {
xmlStr = [xmlStr stringByAppendingString:[NSString stringWithFormat:#"<recipient><person path='/people/%#' /></recipient>",
[toIdArray objectAtIndex:l]]];
}
xmlStr = [xmlStr stringByAppendingString:[NSString stringWithFormat:#"</recipients><subject>%#</subject><body>%#</body></mailbox-item>",
#"Message from butterfli",[shareDict objectForKey:#"text_message"]]];
[NSString stringWithFormat:#"<share><comment>%#</comment><content><submitted-url>%#</submitted-url></content><visibility><code>anyone</code></visibility></share>",
[shareDict objectForKey:#"link_msg"],[shareDict objectForKey:#"link"]];
NSData *body = [xmlStr dataUsingEncoding:NSUTF8StringEncoding];
NSLog(#"xmlStr..%#",xmlStr);
return [self sendAPIRequestWithURL:url HTTPMethod:#"POST" body:body];
}
Amit Battan
its not a closed issue before it...
But now the solution is
its done...
Before it I am hardcoded the user id which is shown in the URL of user profile on Web.
But its working ok with id of user which is coming through API ..
But not getting why linkedin user different ids??
as
LinkedIn use unique user IDs for each user/application combination to protect user's privacy. Only the application which originally requested (and got) authentication from the member can use that token to retrieve further information.
http://developer.linkedin.com/thread/3044

Editing Mac OS X login items in Objective-C through AppleScript

In my Cocoa program, I want to examine what programs are registered to run at startup and modify that list as I feel appropriate. In order to be compatible with Tiger it seems like I need to work through AppleScript. I currently have the following code:
NSDictionary* errorDict;
NSAppleEventDescriptor* returnDescriptor = NULL;
NSString *appleSource = #"tell application \"System Events\"\n\
get every login item\n\
end tell";
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource: appleSource];
returnDescriptor = [appleScript executeAndReturnError: &errorDict];
If I run that command in AppleScript, I get back an array of login items. However, I can't figure out how to iterate through this array in Objective-C. More specifically, I want to examine the names and paths of the programs registered to run at startup.
Any ideas?
Edit: I figured this out. Here is some sample code. The key is using AEKeyword's, which are very poorly documented. The best reference is here: http://developer.apple.com/mac/library/releasenotes/AppleScript/ASTerminology_AppleEventCodes/TermsAndCodes.html
const AEKeyword aeName = 'pnam';
const AEKeyword aePath = 'ppth';
...
NSDictionary* errorDict;
NSAppleEventDescriptor* getLoginItemsRD = NULL;
NSString *getLoginItemsSrc = #"tell application \"System Events\"\n\
get properties of every login item\n\
end tell";
NSAppleScript *getLoginItemsScript = [[NSAppleScript alloc] initWithSource: getLoginItemsSrc];
getLoginItemsRD = [getLoginItemsScript executeAndReturnError: &errorDict];
[getLoginItemsScript release];
int i;
int numLoginItems = [getLoginItemsRD numberOfItems];
for (i = 1; i <= numLoginItems; i++)
{
NSAppleEventDescriptor *loginItem = [getLoginItemsRD descriptorAtIndex:i];
NSString *loginItemName = [[loginItem descriptorForKeyword:aeName] stringValue];
NSString *loginItemPath = [[loginItem descriptorForKeyword:aePath] stringValue];
}
Apple has some source code which can manage login items for Tiger and earlier. I believe you're supposed to get it from ADC but I found it floating around here:
LoginItemAPI.h
LoginItemAPI.c