diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/APNSManager.m b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/APNSManager.m index a6f1911c..57428a69 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/APNSManager.m +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/APNSManager.m @@ -240,6 +240,7 @@ - (void) pushData:(NSString*) filePath sendingRich:(BOOL) sendingRich messageID: - (void) registerDeviceToken:(NSData*) devToken { + OPLog(HOPLoggerSeverityInformational, HOPLoggerLevelDebug, @"Registering device token, %@, with Urban Airship",devToken); [[UAPush shared] appRegisteredForRemoteNotificationsWithDeviceToken:devToken]; } @@ -638,7 +639,8 @@ - (void) requestDeviceTokenForPeerURI:(NSString*) peerURI json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } - HTTPDownloader* request = [[HTTPDownloader alloc] initDownloadFromURL:@"http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-get" data:json post:YES]; + //HTTPDownloader* request = [[HTTPDownloader alloc] initDownloadFromURL:@"http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-get" data:json post:YES]; + HTTPDownloader* request = [[HTTPDownloader alloc] initDownloadFromURL:[[Settings sharedSettings] getDeviceTokenDownloadURL] data:json post:YES]; request.delegate = self; [self.dictionaryOfHTTPRequests setObject:request forKey:peerURI]; @@ -658,6 +660,8 @@ - (void) registerDeviceToken if ([self.deviceToken length] > 0 && [peerURI length] > 0 && ![[self.dictionaryOfHTTPRequests allKeys] containsObject:peerURI]) { + OPLog(HOPLoggerSeverityInformational, HOPLoggerLevelDebug, @"Registering device token, %@, with Open Peer system",self.deviceToken); + NSMutableDictionary* dictRoot = [[NSMutableDictionary alloc] init]; NSMutableDictionary* dictData = [[NSMutableDictionary alloc] init]; @@ -686,7 +690,8 @@ - (void) registerDeviceToken json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } - HTTPDownloader* request = [[HTTPDownloader alloc] initDownloadFromURL:@"http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-set" data:json post:YES]; + //HTTPDownloader* request = [[HTTPDownloader alloc] initDownloadFromURL:@"http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-set" data:json post:YES]; + HTTPDownloader* request = [[HTTPDownloader alloc] initDownloadFromURL:[[Settings sharedSettings] getDeviceTokenUploadURL] data:json post:YES]; request.delegate = self; [self.dictionaryOfHTTPRequests setObject:request forKey:peerURI]; @@ -694,7 +699,11 @@ - (void) registerDeviceToken if (![request startDownload]) { [self.dictionaryOfHTTPRequests removeObjectForKey:peerURI]; - OPLog(HOPLoggerSeverityError, HOPLoggerLevelDebug, @"Device token registration request is not sent."); + OPLog(HOPLoggerSeverityError, HOPLoggerLevelDebug, @"Device token, %@, registration request is not sent via %@.",self.deviceToken,@"http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-set"); + } + else + { + OPLog(HOPLoggerSeverityInformational, HOPLoggerLevelDebug, @"Registering device token, %@, JSON: /n is sent via %@.",self.deviceToken,json,@"http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-set"); } } } @@ -735,6 +744,7 @@ - (void) httpDownloader:(HTTPDownloader*) downloader downloaded:(NSString*) down NSString* deviceToken = [result objectForKey:@"deviceToken"]; if ([deviceToken length] > 0) { + OPLog(HOPLoggerSeverityInformational, HOPLoggerLevelDebug, @"Received deviceToken, %@, for peer URI %@.",deviceToken,peerURI); [[HOPModelManager sharedModelManager] setAPNSData:deviceToken type:type PeerURI:peerURI]; HOPMessage* msg = [self.dictionaryOfPushNotificationsToSend objectForKey:peerURI]; if (msg) diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.h b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.h index ec11b742..cd00d841 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.h +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.h @@ -60,6 +60,8 @@ extern NSString * const settingsKeySettingsVersion; extern NSString * const settingsKeyBackgroundingPhaseRichPush; extern NSString * const settingsKeyDefaultLogLevel; extern NSString * const settingsKeyRedirectAfterLoginCompleteURL; +extern NSString * const settingsDeviceTokenDownloadURL; +extern NSString * const settingsDeviceTokenUploadURL; extern NSString * const archiveEnabled; extern NSString * const archiveServer; diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.m b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.m index 7654523d..df26ce61 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.m +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppConsts.m @@ -78,6 +78,8 @@ NSString * const settingsKeyBackgroundingPhaseRichPush = @"applicationSettingsBackgroundingPhaseRichPush"; NSString * const settingsKeyDefaultLogLevel = @"logLevelForServicesHttp"; NSString * const settingsKeyRedirectAfterLoginCompleteURL = @"redirectAfterLoginCompleteURL"; +NSString * const settingsDeviceTokenDownloadURL = @"deviceTokenDownloadURL"; +NSString * const settingsDeviceTokenUploadURL = @"deviceTokenUploadURL"; NSString * const archiveEnabled = @"enabled"; NSString * const archiveServer = @"Server"; diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppDelegate.m b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppDelegate.m index 475e732d..eb99ee6e 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppDelegate.m +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppDelegate.m @@ -156,7 +156,7 @@ - (void)application:(UIApplication *)application didRegisterForRemoteNotificatio if ([hexString length] > 0) { - OPLog(HOPLoggerSeverityInformational, HOPLoggerLevelDebug, @"Push notification deviceToken:%@",hexString); + OPLog(HOPLoggerSeverityInformational, HOPLoggerLevelDebug, @"Registered push notification deviceToken:%@",hexString); [[APNSManager sharedAPNSManager] setDeviceToken:hexString]; [[APNSManager sharedAPNSManager] registerDeviceToken:deviceToken]; diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppInfoViewController.m b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppInfoViewController.m index f3b31694..103fbb7c 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppInfoViewController.m +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/AppInfoViewController.m @@ -31,6 +31,7 @@ #import "AppInfoViewController.h" #import "AppConsts.h" +#import "Settings.h" const CGFloat cellDefaultHeight = 50.0; const CGFloat headerDefaultHeight = 40.0; @@ -40,10 +41,17 @@ APP_VERSION, APP_BUILD_VERSION, - APP_SETTINGS_DOWNLOAD_URL, APP_SETTINGS_VERSION, + APP_SETTINGS_DOWNLOAD_URL, + APP_SETTINGS_OUTER_FRAME_URL, + APP_SETTINGS_IDENTITY_PROVIDER_DOMAIN, + APP_SETTINGS_IDENTITY_FEDERATE_BASE_URI, + APP_SETTINGS_NAMESPACE_GRANT_SERVICE_URL, + APP_SETTINGS_LOCKBOX_SERVICE_DOMAIN, + APP_SETTINGS_DEVICE_TOKEN_DOWNLOAD_URL, + APP_SETTINGS_DEVICE_TOKEN_UPLOAD_URL, - APP_INFO_SECTIONS = 4 + APP_INFO_SECTIONS } AppInfoOptions; @interface AppInfoViewController () @@ -111,14 +119,44 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.textLabel.text = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; break; + case APP_SETTINGS_VERSION: + cell.textLabel.text = [[NSUserDefaults standardUserDefaults] stringForKey:settingsKeySettingsVersion]; + break; + case APP_SETTINGS_DOWNLOAD_URL: cell.textLabel.text = [[[NSUserDefaults standardUserDefaults] stringForKey:settingsKeySettingsDownloadURL] length] > 0 ? [[NSUserDefaults standardUserDefaults] stringForKey:settingsKeySettingsDownloadURL] : @"None"; break; - case APP_SETTINGS_VERSION: - cell.textLabel.text = [[NSUserDefaults standardUserDefaults] stringForKey:settingsKeySettingsVersion]; + + case APP_SETTINGS_OUTER_FRAME_URL: + cell.textLabel.text = [[[Settings sharedSettings] getOuterFrameURL] length] > 0 ? [[Settings sharedSettings] getOuterFrameURL]: @"None"; + break; + + case APP_SETTINGS_IDENTITY_PROVIDER_DOMAIN: + cell.textLabel.text = [[[Settings sharedSettings] getIdentityProviderDomain] length] > 0 ? [[Settings sharedSettings] getIdentityProviderDomain]: @"None"; + break; + + case APP_SETTINGS_IDENTITY_FEDERATE_BASE_URI: + cell.textLabel.text = [[[Settings sharedSettings] getIdentityFederateBaseURI] length] > 0 ? [[Settings sharedSettings] getIdentityFederateBaseURI]: @"None"; + break; + + case APP_SETTINGS_NAMESPACE_GRANT_SERVICE_URL: + cell.textLabel.text = [[[Settings sharedSettings] getNamespaceGrantServiceURL] length] > 0 ? [[Settings sharedSettings] getNamespaceGrantServiceURL]: @"None"; + break; + + case APP_SETTINGS_LOCKBOX_SERVICE_DOMAIN: + cell.textLabel.text = [[[Settings sharedSettings] getLockBoxServiceDomain] length] > 0 ? [[Settings sharedSettings] getLockBoxServiceDomain]: @"None"; + break; + + case APP_SETTINGS_DEVICE_TOKEN_DOWNLOAD_URL: + cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping; + cell.textLabel.text = [[[Settings sharedSettings] getDeviceTokenDownloadURL] length] > 0 ? [[Settings sharedSettings] getDeviceTokenDownloadURL]: @"None"; + break; + + case APP_SETTINGS_DEVICE_TOKEN_UPLOAD_URL: + cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping; + cell.textLabel.text = [[[Settings sharedSettings] getDeviceTokenUploadURL] length] > 0 ? [[Settings sharedSettings] getDeviceTokenUploadURL]: @"None"; break; - default: break; @@ -140,20 +178,79 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte case APP_BUILD_VERSION: ret = @"Application Build Version"; break; + + case APP_SETTINGS_VERSION: + ret = @"Settings Version"; + break; case APP_SETTINGS_DOWNLOAD_URL: ret = @"Settings Download URL"; break; - case APP_SETTINGS_VERSION: - ret = @"Settings Version"; + case APP_SETTINGS_OUTER_FRAME_URL: + ret = @"Outer Frame URL"; break; + case APP_SETTINGS_IDENTITY_PROVIDER_DOMAIN: + ret = @"Settings Identity Provider Domain"; + break; + + case APP_SETTINGS_IDENTITY_FEDERATE_BASE_URI: + ret = @"Identity Federate Base URI"; + break; + + case APP_SETTINGS_NAMESPACE_GRANT_SERVICE_URL: + ret = @"Namespace Grant Service URL"; + break; + + case APP_SETTINGS_LOCKBOX_SERVICE_DOMAIN: + ret = @"Settings Lockbox Service Domain"; + break; + + case APP_SETTINGS_DEVICE_TOKEN_DOWNLOAD_URL: + ret = @"Device Token Download URL"; + break; + + case APP_SETTINGS_DEVICE_TOKEN_UPLOAD_URL: + ret = @"Device Token Upload URL"; + break; + + default: + break; + } + + return ret; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + CGFloat ret = 0; + CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT); + + switch (indexPath.section) + { + case APP_SETTINGS_DEVICE_TOKEN_DOWNLOAD_URL: + { + UIFont* cellFont = [UIFont boldSystemFontOfSize:17.0]; + CGSize labelSize = [[[Settings sharedSettings] getDeviceTokenDownloadURL] boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size; + ret = (labelSize.height) > cellDefaultHeight ? labelSize.height + 20.0: cellDefaultHeight; + } + break; + + case APP_SETTINGS_DEVICE_TOKEN_UPLOAD_URL: + { + UIFont* cellFont = [UIFont boldSystemFontOfSize:17.0]; + CGSize labelSize = [[[Settings sharedSettings] getDeviceTokenUploadURL] boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size; + ret = (labelSize.height) > cellDefaultHeight ? labelSize.height + 20.0: cellDefaultHeight; + } + break; default: + ret = cellDefaultHeight; break; } return ret; } + @end diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/DefaultSettings.plist b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/DefaultSettings.plist index 599a9584..9c552a68 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/DefaultSettings.plist +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/DefaultSettings.plist @@ -3,21 +3,25 @@ outerFrameURL - http://identity.opp.me:5005/outer-new.html + http://identity.hcs.io:5005/outer-new.html identityProviderDomain - com-hookflash-sergejfb.app.opp.me + com-hookflash-sampleapp.app.hcs.io identityFederateBaseURI identity://facebook.com/ namespaceGrantServiceURL - http://jsouter-v1-rel-lespaulinst2-i.hcs.io/grant.html + http://identity.hcs.io:5005/outernamespacegrant.html lockBoxServiceDomain - opp.me + hcs.io defaultOutgoingTelnetServer - log.opp.me:8115 + log.hcs.io:8115 localTelnetLoggerPort 59999 applicationSettingsBackgroundingPhaseRichPush 4 + deviceTokenDownloadURL + http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-get + deviceTokenUploadURL + http://push-hack.hcs-stack-v2-i7957106-7.hcs.io/device-associate-set openpeer/core/core-thread-priority normal openpeer/core/media-thread-priority diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.h b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.h index 4ab7413f..1c52cccd 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.h +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.h @@ -32,6 +32,10 @@ #import #import +@class HOPOpenPeerContact; + @interface InfoViewController : UITableViewController +- (id) initWithContact:(HOPOpenPeerContact*) inContact style:(UITableViewStyle)style; + @end diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.m b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.m index 42ba46b7..149c04df 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.m +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/InfoViewController.m @@ -30,35 +30,53 @@ */ #import "InfoViewController.h" +#import "OpenPeer.h" #import -#import +#import #import #import #import #import #import -#import +#import +#import +#import + const CGFloat cellDefaultHeight = 50.0; const CGFloat headerDefaultHeight = 40.0; typedef enum { + USER_INFO_NAME, USER_INFO_STABLE_ID, USER_INFO_PEER_URI, USER_INFO_IDENTITIES, + USER_INFO_DEVICE_TOKEN, - USER_INFO_SECTIONS = 3 + USER_INFO_SECTIONS } UserInfoOptions; @interface InfoViewController () @property (nonatomic, strong) HOPOpenPeerAccount* homeUser; +@property (nonatomic, strong) HOPOpenPeerContact* contact; +@property (nonatomic) BOOL showContactInfo; @end @implementation InfoViewController +- (id) initWithContact:(HOPOpenPeerContact*) inContact style:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) + { + self.contact = inContact; + self.showContactInfo = self.contact != nil; + } + return self; +} - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; @@ -71,7 +89,7 @@ - (id)initWithStyle:(UITableViewStyle)style - (void)viewDidLoad { [super viewDidLoad]; - + //self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iPhone_background_navigation_mode.png"]]; self.homeUser = [[HOPModelManager sharedModelManager] getLastLoggedInUser]; @@ -101,13 +119,15 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger switch (section) { + case USER_INFO_NAME: case USER_INFO_STABLE_ID: case USER_INFO_PEER_URI: + case USER_INFO_DEVICE_TOKEN: ret = 1; break; case USER_INFO_IDENTITIES: - ret = [self.homeUser.associatedIdentities count]; + ret = self.showContactInfo ? self.contact.identityContacts.count : [self.homeUser.associatedIdentities count]; break; default: @@ -128,33 +148,54 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell = [[UITableViewCell alloc] initWithStyle:cellStyle reuseIdentifier:cellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } - + switch (indexPath.section) { + case USER_INFO_NAME: + cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; + cell.textLabel.numberOfLines = 0; + cell.textLabel.text = self.showContactInfo ? [self.contact getFullName] : [self.homeUser getFullName]; + break; + case USER_INFO_STABLE_ID: cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; cell.textLabel.numberOfLines = 0; - cell.textLabel.text = self.homeUser.stableId; + cell.textLabel.text = self.showContactInfo ? self.contact.stableID : self.homeUser.stableId; break; - case USER_INFO_PEER_URI:cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; + case USER_INFO_PEER_URI: + cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; cell.textLabel.numberOfLines = 0; - cell.textLabel.text = ((HOPAssociatedIdentity*)self.homeUser.associatedIdentities.anyObject).selfRolodexContact.identityContact.openPeerContact.publicPeerFile.peerURI; + cell.textLabel.text = self.showContactInfo ? self.contact.publicPeerFile.peerURI : ((HOPAssociatedIdentity*)self.homeUser.associatedIdentities.anyObject).selfRolodexContact.identityContact.openPeerContact.publicPeerFile.peerURI; break; case USER_INFO_IDENTITIES: { - HOPAssociatedIdentity* identityInfo = [[self.homeUser.associatedIdentities allObjects] objectAtIndex:indexPath.row]; + HOPRolodexContact* rolodex = nil; + if (self.showContactInfo) + { + rolodex = ((HOPIdentityContact*)[[self.contact.identityContacts allObjects] objectAtIndex:indexPath.row]).rolodexContact; + } + else + { + HOPAssociatedIdentity* identityInfo = [[self.homeUser.associatedIdentities allObjects] objectAtIndex:indexPath.row]; + rolodex = identityInfo.selfRolodexContact; + } cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; cell.textLabel.numberOfLines = 0; - cell.textLabel.text = identityInfo.identityProvider.name; + cell.textLabel.text = rolodex.associatedIdentity.identityProvider.name; cell.detailTextLabel.lineBreakMode = NSLineBreakByCharWrapping; cell.detailTextLabel.numberOfLines = 0; - cell.detailTextLabel.text = [NSString stringWithFormat:@"Identity URI: %@",identityInfo.selfRolodexContact.identityURI]; + cell.detailTextLabel.text = [NSString stringWithFormat:@"Identity URI: %@",rolodex.identityURI]; } break; + case USER_INFO_DEVICE_TOKEN: + cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; + cell.textLabel.numberOfLines = 0; + cell.textLabel.text = self.showContactInfo ? self.contact.apnsData.deviceToken : ((OpenPeer*)[OpenPeer sharedOpenPeer]).deviceToken; + break; default: break; } @@ -169,19 +210,29 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa switch (indexPath.section) { + case USER_INFO_NAME: + { + NSString* value = self.showContactInfo ? [self.contact getFullName] : [self.homeUser getFullName]; + UIFont* cellFont = [UIFont boldSystemFontOfSize:17.0]; + CGSize labelSize = [value boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size; + ret = (labelSize.height) > cellDefaultHeight ? labelSize.height : cellDefaultHeight; + } + break; + case USER_INFO_STABLE_ID: { + NSString* value = self.showContactInfo ? self.contact.stableID : self.homeUser.stableId; UIFont* cellFont = [UIFont boldSystemFontOfSize:17.0]; - CGSize labelSize = [self.homeUser.stableId boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size;//[self.homeUser.stableId sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByCharWrapping]; + CGSize labelSize = [value boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size; ret = (labelSize.height) > cellDefaultHeight ? labelSize.height : cellDefaultHeight; } - break; + break; case USER_INFO_PEER_URI: { UIFont* cellFont = [UIFont boldSystemFontOfSize:17.0]; //NSString* str = ((HOPRolodexContact*)((HOPAssociatedIdentity*)self.homeUser.associatedIdentities.anyObject).rolodexContacts.anyObject).identityContact.peerFile.peerURI; - NSString* str = ((HOPRolodexContact*)((HOPAssociatedIdentity*)self.homeUser.associatedIdentities.anyObject).selfRolodexContact).identityContact.openPeerContact.publicPeerFile.peerURI; + NSString* str = self.showContactInfo ? self.contact.publicPeerFile.peerURI : ((HOPRolodexContact*)((HOPAssociatedIdentity*)self.homeUser.associatedIdentities.anyObject).selfRolodexContact).identityContact.openPeerContact.publicPeerFile.peerURI; CGSize labelSize = [str boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size;//[str sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByCharWrapping]; ret = labelSize.height > cellDefaultHeight ? labelSize.height : cellDefaultHeight; } @@ -189,20 +240,39 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa case USER_INFO_IDENTITIES: { + HOPRolodexContact* rolodex = nil; + if (self.showContactInfo) + { + rolodex = ((HOPIdentityContact*)[[self.contact.identityContacts allObjects] objectAtIndex:indexPath.row]).rolodexContact; + } + else + { + HOPAssociatedIdentity* identityInfo = [[self.homeUser.associatedIdentities allObjects] objectAtIndex:indexPath.row]; + rolodex = identityInfo.selfRolodexContact; + } + UIFont* cellFont = [UIFont boldSystemFontOfSize:17.0]; UIFont* cellDetailFont = [UIFont boldSystemFontOfSize:14.0]; HOPAssociatedIdentity* identityInfo = [[self.homeUser.associatedIdentities allObjects] objectAtIndex:indexPath.row]; CGSize labelSize = [identityInfo.identityProvider.name boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size;//[identityInfo.name sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByCharWrapping]; - NSString* str = [NSString stringWithFormat:@"Identity URI: %@",identityInfo.selfRolodexContact.identityURI]; + NSString* str = [NSString stringWithFormat:@"Identity URI: %@",rolodex.identityURI]; CGSize labelDetailSize = [str boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellDetailFont } context: nil].size;//[str sizeWithFont:cellDetailFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByCharWrapping]; CGFloat totalCellHeight = labelSize.height + labelDetailSize.height; ret = (totalCellHeight) > cellDefaultHeight ? totalCellHeight: cellDefaultHeight; } break; - + + case USER_INFO_DEVICE_TOKEN: + { + UIFont* cellFont = [UIFont boldSystemFontOfSize:17.0]; + NSString* str = self.showContactInfo ? self.contact.apnsData.deviceToken : ((OpenPeer*)[OpenPeer sharedOpenPeer]).deviceToken; + CGSize labelSize = [str boundingRectWithSize: constraintSize options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: cellFont } context: nil].size; + ret = (labelSize.height) > cellDefaultHeight ? labelSize.height : cellDefaultHeight; + } + break; default: break; } @@ -225,6 +295,10 @@ - (UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger switch (section) { + case USER_INFO_NAME: + ret.text = @"Name"; + break; + case USER_INFO_STABLE_ID: ret.text = @"Stable Id"; break; @@ -236,6 +310,10 @@ - (UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger case USER_INFO_IDENTITIES: ret.text = @"Associated Identities"; break; + + case USER_INFO_DEVICE_TOKEN: + ret.text = @"Device Token"; + break; default: break; @@ -243,7 +321,6 @@ - (UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger [customTitleView addSubview:ret]; return customTitleView; - } @end diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/SessionViewController_iPhone.m b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/SessionViewController_iPhone.m index 94b5f2e3..2a34a1d7 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/SessionViewController_iPhone.m +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/SessionViewController_iPhone.m @@ -39,14 +39,18 @@ #import "WaitingVideoViewController.h" #import "Utility.h" #import "AddParticipantsViewController.h" +#import "InfoViewController.h" #import #import #import -#define ACTION_AUDIO_CALL 1 -#define ACTION_VIDEO_CALL 2 -#define ACTION_ADD_CONTACT 3 -#define ACTION_REMOVE_CONTACT 4 -#define ACTION_CANCEL 5 + + +#define ACTION_AUDIO_CALL 1 +#define ACTION_VIDEO_CALL 2 +#define ACTION_ADD_CONTACT 3 +#define ACTION_REMOVE_CONTACT 4 +#define ACTION_SHOW_CONTACT_INFO 5 +#define ACTION_CANCEL 6 @interface SessionViewController_iPhone () @@ -260,6 +264,13 @@ - (void) actionCallMenu [buttonTitles addObject:NSLocalizedString(@"Remove Contact", @"")]; [self.availableActions addObject:[NSNumber numberWithInt:ACTION_REMOVE_CONTACT]]; } + + if (self.session.lastConversationEvent.participants.participants.count == 1) + { + [buttonTitles addObject:NSLocalizedString(@"Show contact info", @"")]; + [self.availableActions addObject:[NSNumber numberWithInt:ACTION_SHOW_CONTACT_INFO]]; + } + [buttonTitles addObject:NSLocalizedString(@"Cancel", @"")]; [self.availableActions addObject:[NSNumber numberWithInt:ACTION_CANCEL]]; @@ -283,6 +294,13 @@ - (void) showContactsChooserForAddingContacts:(BOOL) addingContacts [self.navigationController pushViewController:self.addParticipantsViewController animated:YES]; } +- (void) showContactInfo +{ + InfoViewController* infoViewController = [[InfoViewController alloc] initWithContact:[self.session.lastConversationEvent.participants.participants.allObjects objectAtIndex:0] style:UITableViewStyleGrouped]; + infoViewController.title = @"User Info"; + [self.navigationController pushViewController:infoViewController animated:YES]; +} + #pragma mark - UIActionSheetDelegate - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; { @@ -304,6 +322,9 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger [self showContactsChooserForAddingContacts:NO]; //[self closeSession:nil]; break; + case ACTION_SHOW_CONTACT_INFO: + [self showContactInfo]; + break; default: break; } diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.h b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.h index 9b33dfb6..677e9f02 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.h +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.h @@ -139,6 +139,8 @@ typedef enum - (NSString*) getIdentityFederateBaseURI; - (NSString*) getLockBoxServiceDomain; - (NSString*) getDefaultOutgoingTelnetServer; +- (NSString*) getDeviceTokenDownloadURL; +- (NSString*) getDeviceTokenUploadURL; - (BOOL) isAppDataSet; - (BOOL) isLoginSettingsSet; diff --git a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.m b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.m index a51b3f7c..e46a39ef 100644 --- a/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.m +++ b/Samples/OpenPeerSampleApp/OpenPeerSampleApp/Settings.m @@ -596,6 +596,17 @@ - (NSString*) getDefaultOutgoingTelnetServer { return [[NSUserDefaults standardUserDefaults] stringForKey:settingsKeyOutgoingTelnetLogger]; } + +- (NSString*) getDeviceTokenDownloadURL +{ + return [[NSUserDefaults standardUserDefaults] stringForKey:settingsDeviceTokenDownloadURL]; +} + +- (NSString*) getDeviceTokenUploadURL +{ + return [[NSUserDefaults standardUserDefaults] stringForKey:settingsDeviceTokenUploadURL]; +} + - (BOOL) isAppDataSet { BOOL ret = YES; diff --git a/openpeer-ios-sdk/model/HOPOpenPeerContact+External.h b/openpeer-ios-sdk/model/HOPOpenPeerContact+External.h index 1b3bef13..c62ab50d 100644 --- a/openpeer-ios-sdk/model/HOPOpenPeerContact+External.h +++ b/openpeer-ios-sdk/model/HOPOpenPeerContact+External.h @@ -38,5 +38,5 @@ - (HOPContact*) getCoreContact; - (HOPRolodexContact*) getDefaultRolodexContact; - +- (NSString*) getFullName; @end diff --git a/openpeer-ios-sdk/model/HOPOpenPeerContact+External.mm b/openpeer-ios-sdk/model/HOPOpenPeerContact+External.mm index abc1fafa..b55d41cf 100644 --- a/openpeer-ios-sdk/model/HOPOpenPeerContact+External.mm +++ b/openpeer-ios-sdk/model/HOPOpenPeerContact+External.mm @@ -62,4 +62,8 @@ - (HOPRolodexContact*) getDefaultRolodexContact return ret; } +- (NSString*) getFullName +{ + return [self getDefaultRolodexContact].name; +} @end \ No newline at end of file