mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 16:49:20 +00:00
InCallView: add contact image
This commit is contained in:
parent
26eaffe005
commit
8447bdb15c
6 changed files with 54 additions and 11 deletions
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
#import "IncallViewController.h"
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
#import <AddressBook/AddressBook.h>
|
||||
#import "linphonecore.h"
|
||||
#include "LinphoneManager.h"
|
||||
#include "private.h"
|
||||
|
|
@ -161,15 +162,15 @@ int callCount(LinphoneCore* lc) {
|
|||
[self updateUIFromLinphoneState: nil];
|
||||
}
|
||||
|
||||
-(void) viewWillAppear:(BOOL)animated {
|
||||
}
|
||||
-(void) viewWillAppear:(BOOL)animated {}
|
||||
|
||||
-(void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
if (dismissed) {
|
||||
[self dismissModalViewControllerAnimated:true];
|
||||
} else {
|
||||
[self updateCallsDurations];
|
||||
durationRefreasher = [NSTimer scheduledTimerWithTimeInterval:1
|
||||
durationRefreasher = [NSTimer scheduledTimerWithTimeInterval:1
|
||||
target:self
|
||||
selector:@selector(updateCallsDurations)
|
||||
userInfo:nil
|
||||
|
|
@ -457,17 +458,25 @@ int callCount(LinphoneCore* lc) {
|
|||
return;
|
||||
}
|
||||
const LinphoneAddress* addr = linphone_call_get_remote_address(call);
|
||||
|
||||
if (addr) {
|
||||
NSMutableString* mss = [[NSMutableString alloc] init];
|
||||
|
||||
/* contact name */
|
||||
const char* n = linphone_address_get_display_name(addr);
|
||||
if (n)
|
||||
[mss appendFormat:@"%s", n, nil];
|
||||
else
|
||||
[mss appendFormat:@"%s", linphone_address_get_username(addr), nil];
|
||||
[cell.textLabel setText:mss];
|
||||
} else
|
||||
|
||||
if ([mss compare:cell.textLabel.text] != 0 || cell.imageView.image == nil) {
|
||||
[cell.textLabel setText:mss];
|
||||
|
||||
cell.imageView.image = [[LinphoneManager instance] getImageFromAddressBook:[NSString stringWithCString:linphone_address_get_username(addr) encoding: [NSString defaultCStringEncoding]]];
|
||||
}
|
||||
} else {
|
||||
[cell.textLabel setText:@"plop"];
|
||||
cell.imageView.image = nil;
|
||||
}
|
||||
|
||||
NSMutableString* ms = [[NSMutableString alloc] init ];
|
||||
if (linphone_call_get_state(call) == LinphoneCallStreamsRunning) {
|
||||
|
|
@ -549,6 +558,7 @@ int callCount(LinphoneCore* lc) {
|
|||
calls = calls->next;
|
||||
}
|
||||
[cell.detailTextLabel setText:ms];
|
||||
cell.imageView.image = nil;
|
||||
|
||||
/*if (linphone_core_is_in_conference(lc))
|
||||
cell.backgroundColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:1];
|
||||
|
|
@ -664,7 +674,7 @@ int callCount(LinphoneCore* lc) {
|
|||
linphone_core_resume_call([LinphoneManager getLc], selectedCall);
|
||||
}
|
||||
|
||||
[self updateUIFromLinphoneState: nil];
|
||||
[self updateUIFromLinphoneState: nil];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@
|
|||
@end
|
||||
|
||||
@interface FastAddressBook : NSObject {
|
||||
NSMutableDictionary* mAddressBookMap;
|
||||
NSMutableDictionary* mAddressBookMap;
|
||||
|
||||
ABAddressBookRef addressBook;
|
||||
}
|
||||
|
||||
-(Contact*) getMatchingRecord:(NSString*) number ;
|
||||
|
|
@ -38,4 +40,6 @@
|
|||
+(NSString*) normalizePhoneNumber:(NSString*) number ;
|
||||
-(id) init ;
|
||||
|
||||
@property (nonatomic, readonly) ABAddressBookRef addressBook;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#import "FastAddressBook.h"
|
||||
@implementation FastAddressBook
|
||||
|
||||
@synthesize addressBook;
|
||||
|
||||
-(Contact*) getMatchingRecord:(NSString*) number {
|
||||
@synchronized (mAddressBookMap){
|
||||
return (Contact*) [mAddressBookMap objectForKey:number];
|
||||
|
|
@ -71,9 +73,9 @@ void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef info, void
|
|||
-(FastAddressBook*) init {
|
||||
if ((self = [super init])) {
|
||||
mAddressBookMap = [[NSMutableDictionary alloc] init];
|
||||
ABAddressBookRef lAddressBook = ABAddressBookCreate();
|
||||
ABAddressBookRegisterExternalChangeCallback (lAddressBook,sync_address_book,mAddressBookMap);
|
||||
sync_address_book(lAddressBook,nil,mAddressBookMap);
|
||||
addressBook = ABAddressBookCreate();
|
||||
ABAddressBookRegisterExternalChangeCallback (addressBook,sync_address_book,mAddressBookMap);
|
||||
sync_address_book(addressBook,nil,mAddressBookMap);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ typedef enum _Connectivity {
|
|||
-(void) becomeActive;
|
||||
-(void) kickOffNetworkConnection;
|
||||
-(NSString*) getDisplayNameFromAddressBook:(NSString*) number andUpdateCallLog:(LinphoneCallLog*)log;
|
||||
-(UIImage*) getImageFromAddressBook:(NSString*) number;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,28 @@ extern void libmssilk_init();
|
|||
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(UIImage*) getImageFromAddressBook:(NSString *)number {
|
||||
NSString* lNormalizedNumber = [FastAddressBook normalizePhoneNumber:number];
|
||||
Contact* lContact = [mFastAddressBook getMatchingRecord:lNormalizedNumber];
|
||||
if (lContact) {
|
||||
ABRecordRef person = ABAddressBookGetPersonWithRecordID(mFastAddressBook.addressBook, ABRecordGetRecordID(lContact.record));
|
||||
if (ABPersonHasImageData(person)) {
|
||||
NSData* d;
|
||||
// ios 4.1+
|
||||
if ( &ABPersonCopyImageDataWithFormat != nil) {
|
||||
d = (NSData*)ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail);
|
||||
} else {
|
||||
d = (NSData*)ABPersonCopyImageData(person);
|
||||
}
|
||||
return [UIImage imageWithData:d];
|
||||
}
|
||||
}
|
||||
/* return default image */
|
||||
return [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"contact_vide" ofType:@"png"]];
|
||||
//return nil;
|
||||
}
|
||||
|
||||
-(void) updateCallWithAddressBookData:(LinphoneCall*) call {
|
||||
//1 copy adress book
|
||||
LinphoneCallLog* lLog = linphone_call_get_call_log(call);
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@
|
|||
22F254811073D99800AC9B3F /* ringback.wav in Resources */ = {isa = PBXBuildFile; fileRef = 22F254801073D99800AC9B3F /* ringback.wav */; };
|
||||
22F51EF6107FA66500F98953 /* untitled.plist in Resources */ = {isa = PBXBuildFile; fileRef = 22F51EF5107FA66500F98953 /* untitled.plist */; };
|
||||
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
|
||||
34F2F678147D2E1C00A2D5E3 /* contact_vide.png in Resources */ = {isa = PBXBuildFile; fileRef = 34F2F677147D2E1C00A2D5E3 /* contact_vide.png */; };
|
||||
70571E1A13FABCB000CDD3C2 /* rootca.pem in Resources */ = {isa = PBXBuildFile; fileRef = 70571E1913FABCB000CDD3C2 /* rootca.pem */; };
|
||||
7066FC0C13E830E400EFC6DC /* libvpx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7066FC0B13E830E400EFC6DC /* libvpx.a */; };
|
||||
70E542F313E147E3002BA2C0 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 70E542F213E147E3002BA2C0 /* OpenGLES.framework */; };
|
||||
|
|
@ -573,6 +574,7 @@
|
|||
288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
32CA4F630368D1EE00C91783 /* linphone_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = linphone_Prefix.pch; sourceTree = "<group>"; };
|
||||
34F2F677147D2E1C00A2D5E3 /* contact_vide.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = contact_vide.png; path = Resources/contact_vide.png; sourceTree = "<group>"; };
|
||||
70571E1913FABCB000CDD3C2 /* rootca.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = rootca.pem; path = Resources/rootca.pem; sourceTree = "<group>"; };
|
||||
7066FC0B13E830E400EFC6DC /* libvpx.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvpx.a; path = "liblinphone-sdk/apple-darwin/lib/libvpx.a"; sourceTree = "<group>"; };
|
||||
70E542F213E147E3002BA2C0 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
|
||||
|
|
@ -1103,6 +1105,7 @@
|
|||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
34F2F677147D2E1C00A2D5E3 /* contact_vide.png */,
|
||||
2211DBCA1476BE7300DEE054 /* ajouter.png */,
|
||||
2211DBCB1476BE7300DEE054 /* clavier.png */,
|
||||
2211DBCC1476BE7300DEE054 /* contact.png */,
|
||||
|
|
@ -1270,6 +1273,7 @@
|
|||
2211DBE51476BE7300DEE054 /* micro.png in Resources */,
|
||||
2211DBE71476BE7300DEE054 /* pause_inactif.png in Resources */,
|
||||
2211DBE91476BE7300DEE054 /* pause.png in Resources */,
|
||||
34F2F678147D2E1C00A2D5E3 /* contact_vide.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue