Skip to content

Commit

Permalink
audio: set new ringtones
Browse files Browse the repository at this point in the history
  • Loading branch information
bagage committed Jan 5, 2016
1 parent a083e1d commit 1258240
Show file tree
Hide file tree
Showing 24 changed files with 162 additions and 66 deletions.
6 changes: 6 additions & 0 deletions Classes/LinphoneCoreSettingsStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ - (void)transformLinphoneCoreToKeys {

[self setBool:[lm lpConfigBoolForKey:@"repeat_call_notification"]
forKey:@"repeat_call_notification_preference"];
NSString *ringtone = ([LinphoneManager bundleFile:[NSString stringWithUTF8String:linphone_core_get_ring(lc)]]
?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"])
.lastPathComponent;
[self setObject:ringtone forKey:@"call_ringtone_preference"];
}

// network section
Expand Down Expand Up @@ -705,6 +709,8 @@ - (BOOL)synchronize {
[lm lpConfigSetString:[self stringForKey:@"voice_mail_uri_preference"] forKey:@"voice_mail_uri"];
[lm lpConfigSetBool:[self boolForKey:@"repeat_call_notification_preference"]
forKey:@"repeat_call_notification"];
NSString *ringtone = [LinphoneManager bundleFile:[self objectForKey:@"call_ringtone_preference"]];
linphone_core_set_ring(lc, ringtone.UTF8String);
}

// network section
Expand Down
57 changes: 33 additions & 24 deletions Classes/LinphoneManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,15 @@ - (void)onCall:(LinphoneCall *)call StateChanged:(LinphoneCallState)state withMe
// iOS8 doesn't need the timer trick for the local notification.
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8 &&
[self lpConfigBoolForKey:@"repeat_call_notification"] == NO) {
data->notification.soundName = @"ring.caf";
NSString *ring =
([LinphoneManager bundleFile:[self lpConfigStringForKey:@"local_ring" inSection:@"sound"]]
?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"])
.lastPathComponent;
NSString *soundName = [NSString stringWithFormat:@"sounds/%@", ring];
data->notification.soundName = soundName;
data->notification.category = @"incoming_call";
} else {
data->notification.soundName = @"shortring.caf";
data->notification.soundName = @"sounds/shortring.caf";
data->timer = [NSTimer scheduledTimerWithTimeInterval:4.0
target:self
selector:@selector(localNotifContinue:)
Expand Down Expand Up @@ -875,6 +880,12 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char
[alertView dismissWithClickedButtonIndex:0 animated:NO];
}

// dont pop up if we are in background, in any case we will refresh registers when entering
// the application again
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
return;
}

NSString *realm = [NSString stringWithUTF8String:realmC];
NSString *username = [NSString stringWithUTF8String:usernameC];
NSString *domain = [NSString stringWithUTF8String:domainC];
Expand Down Expand Up @@ -945,7 +956,7 @@ - (void)onMessageReceived:(LinphoneCore *)lc room:(LinphoneChatRoom *)room messa
notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), from];
}
notif.alertAction = NSLocalizedString(@"Show", nil);
notif.soundName = @"msg.caf";
notif.soundName = @"sounds/msg.caf";
notif.userInfo = @{ @"from" : from, @"from_addr" : remote_uri, @"call-id" : callID };

[[UIApplication sharedApplication] presentLocalNotificationNow:notif];
Expand Down Expand Up @@ -1335,14 +1346,6 @@ - (void)finishCoreConfiguration {
}

linphone_core_set_root_ca(theLinphoneCore, lRootCa);
// Set audio assets
const char *lRing = [[LinphoneManager bundleFile:@"ring.wav"] UTF8String];
linphone_core_set_ring(theLinphoneCore, lRing);
const char *lRingBack = [[LinphoneManager bundleFile:@"ringback.wav"] UTF8String];
linphone_core_set_ringback(theLinphoneCore, lRingBack);
const char *lPlay = [[LinphoneManager bundleFile:@"hold.wav"] UTF8String];
lPlay = NULL;
linphone_core_set_play_file(theLinphoneCore, lPlay);

linphone_core_set_zrtp_secrets_file(theLinphoneCore, [zrtpSecretsFileName UTF8String]);
linphone_core_set_chat_database_path(theLinphoneCore, [chatDBFileName UTF8String]);
Expand Down Expand Up @@ -1460,15 +1463,19 @@ - (void)createLinphoneCore {
libmswebrtc_init();

// Set audio assets
const char *lRing = [[LinphoneManager bundleFile:@"ring.wav"] UTF8String];
lp_config_set_string(configDb, "sound", "local_ring", lRing);
const char *lRingBack = [[LinphoneManager bundleFile:@"ringback.wav"] UTF8String];
lp_config_set_string(configDb, "sound", "ringback_tone", lRingBack);
const char *lPlay = [[LinphoneManager bundleFile:@"hold.wav"] UTF8String];
lp_config_set_string(configDb, "sound", "hold_music", lPlay);

theLinphoneCore =
linphone_core_new_with_config(&linphonec_vtable, configDb, (__bridge void *)(self) /* user_data */);
NSString *ring = ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"local_ring" inSection:@"sound"]]
?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"])
.lastPathComponent;
NSString *ringback = ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"ringback_tone" inSection:@"sound"]]
?: [LinphoneManager bundleFile:@"ringback.wav"])
.lastPathComponent;
NSString *hold = ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"hold_music" inSection:@"sound"]]
?: [LinphoneManager bundleFile:@"hold.caf"])
.lastPathComponent;
[self lpConfigSetString:[LinphoneManager bundleFile:ring] forKey:@"local_ring" inSection:@"sound"];
[self lpConfigSetString:[LinphoneManager bundleFile:ringback] forKey:@"ringback_tone" inSection:@"sound"];
[self lpConfigSetString:[LinphoneManager bundleFile:hold] forKey:@"hold_music" inSection:@"sound"];
theLinphoneCore = linphone_core_new_with_config(&linphonec_vtable, configDb, (__bridge void *)(self));
LOGI(@"Create linphonecore %p", theLinphoneCore);

/* set the CA file no matter what, since the remote provisioning could be hitting an HTTPS server */
Expand Down Expand Up @@ -2009,15 +2016,17 @@ - (void)configurePushTokenForProxyConfig:(LinphoneProxyConfig *)proxyCfg {
}
// NSLocalizedString(@"IC_MSG", nil); // Fake for genstrings
// NSLocalizedString(@"IM_MSG", nil); // Fake for genstrings
// NSLocalizedString(@"IM_FULLMSG", nil); // Fake for genstrings
#ifdef USE_APN_DEV
#define APPMODE_SUFFIX @"dev"
#else
#define APPMODE_SUFFIX @"prod"
#endif
NSString *params =
[NSString stringWithFormat:@"app-id=%@.%@;pn-type=apple;pn-tok=%@;pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-"
@"call-snd=ring.caf;pn-msg-snd=msg.caf",
[[NSBundle mainBundle] bundleIdentifier], APPMODE_SUFFIX, tokenString];
NSString *soundName = @"shortring.caf";
NSString *params = [NSString
stringWithFormat:@"app-id=%@.%@;pn-type=apple;pn-tok=%@;pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-"
@"call-snd=%@;pn-msg-snd=sounds/msg.caf",
[[NSBundle mainBundle] bundleIdentifier], APPMODE_SUFFIX, tokenString, soundName];

linphone_proxy_config_set_contact_uri_parameters(proxyCfg, [params UTF8String]);
linphone_proxy_config_set_contact_parameters(proxyCfg, NULL);
Expand Down
22 changes: 11 additions & 11 deletions Classes/LinphoneUI/Base.lproj/TabBarView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@
<rect key="frame" x="0.0" y="0.0" width="90" height="333"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="hlj-lf-AGD" userLabel="historyButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="35" width="90" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="History"/>
<state key="normal" image="footer_history_default.png"/>
<state key="disabled" image="footer_history_disabled.png"/>
<state key="highlighted" backgroundImage="color_A.png"/>
<connections>
<action selector="onHistoryClick:" destination="-1" eventType="touchUpInside" id="apg-Ia-q2O"/>
</connections>
</button>
<button opaque="NO" tag="3" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="ea1-DR-JeN" userLabel="contactsButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="101" width="90" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
Expand Down Expand Up @@ -222,17 +233,6 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<button opaque="NO" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="hlj-lf-AGD" userLabel="historyButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="35" width="90" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="History"/>
<state key="normal" image="footer_history_default.png"/>
<state key="disabled" image="footer_history_disabled.png"/>
<state key="highlighted" backgroundImage="color_A.png"/>
<connections>
<action selector="onHistoryClick:" destination="-1" eventType="touchUpInside" id="apg-Ia-q2O"/>
</connections>
</button>
</subviews>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
Expand Down
11 changes: 8 additions & 3 deletions Classes/LinphoneUI/UIBouncingView.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@ - (void)dealloc {

- (void)settingsUpdate:(NSNotification *)notif {
if ([[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"] == false) {
[self stopBounceAnimation:kBounceAnimation target:self];
[self stopAnimating:NO];
} else {
if (![self isHidden] && [self.layer animationForKey:kBounceAnimation] == nil) {
[self startBounceAnimation:kBounceAnimation target:self];
if (![self isHidden]) {
self.hidden = YES;
[self startAnimating:YES];
}
}
}

- (void)applicationWillEnterForeground:(NSNotification *)notif {
// Force the animations
if (self.isHidden) {
self.hidden = NO;
[self stopAnimating:NO];
} else {
self.hidden = YES;
[self startAnimating:NO];
}
}
Expand Down Expand Up @@ -96,6 +99,7 @@ - (void)stopBounceAnimation:(NSString *)animationID target:(UIView *)target {
}

- (void)startAnimating:(BOOL)animated {
animated = NO;
if (!self.hidden) {
return;
}
Expand All @@ -118,6 +122,7 @@ - (void)startAnimating:(BOOL)animated {
}

- (void)stopAnimating:(BOOL)animated {
animated = NO;
if (self.hidden) {
return;
}
Expand Down
14 changes: 12 additions & 2 deletions Classes/SettingsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ - (void)viewWillDisappear:(BOOL)animated {
[_settingsController dismiss:self];
// Set observer
[[NSNotificationCenter defaultCenter] removeObserver:self name:kIASKAppSettingChanged object:nil];

if (linphone_ringtoneplayer_is_started(linphone_core_get_ringtoneplayer([LinphoneManager getLc]))) {
linphone_core_stop_ringing([LinphoneManager getLc]);
}
}

- (void)viewWillAppear:(BOOL)animated {
Expand Down Expand Up @@ -411,7 +415,6 @@ - (void)appSettingChanged:(NSNotification *)notif {
[keys addObject:key];
}
}

} else if ([@"video_preset_preference" compare:notif.object] == NSOrderedSame) {
NSString *video_preset = [notif.userInfo objectForKey:@"video_preset_preference"];
removeFromHiddenKeys = [video_preset isEqualToString:@"custom"];
Expand Down Expand Up @@ -694,7 +697,7 @@ - (void)settingsViewController:(IASKAppSettingsViewController *)sender
[alert show];
} else if ([key isEqual:@"about_button"]) {
[PhoneMainView.instance changeCurrentView:AboutView.compositeViewDescription push:TRUE];
} else if ([key isEqualToString:@"reset_logs_button"]) {
} else if ([key isEqual:@"reset_logs_button"]) {
linphone_core_reset_log_collection();
} else if ([key isEqual:@"send_logs_button"]) {
NSString *message;
Expand Down Expand Up @@ -722,6 +725,13 @@ - (void)settingsViewController:(IASKAppSettingsViewController *)sender
[self sendEmailWithDebugAttachments];
}];
[alert show];
} else if ([key isEqual:@"preview_ringtone_button"]) {
LinphoneCore *lc = [LinphoneManager getLc];
if (linphone_ringtoneplayer_is_started(linphone_core_get_ringtoneplayer(lc))) {
linphone_core_stop_ringing(lc);
} else {
linphone_core_preview_ring(lc, linphone_core_get_ring(lc), NULL, NULL);
}
}
}

Expand Down
Binary file removed Resources/msg.caf
Binary file not shown.
Binary file removed Resources/msg.wav
Binary file not shown.
Binary file removed Resources/ring.caf
Binary file not shown.
Binary file removed Resources/ring.wav
Binary file not shown.
Binary file removed Resources/shortring.caf
Binary file not shown.
Binary file added Resources/sounds/hold.caf
Binary file not shown.
Binary file added Resources/sounds/msg.caf
Binary file not shown.
File renamed without changes.
Binary file added Resources/sounds/rings/four_hands_together.caf
Binary file not shown.
Binary file added Resources/sounds/rings/house_keeping.caf
Binary file not shown.
Binary file added Resources/sounds/rings/it_s_a_game.caf
Binary file not shown.
Binary file added Resources/sounds/rings/leaving_a_dream.caf
Binary file not shown.
Binary file not shown.
Binary file added Resources/sounds/rings/soft_as_snow.caf
Binary file not shown.
Binary file added Resources/sounds/shortring.caf
Binary file not shown.
34 changes: 34 additions & 0 deletions Settings/InAppSettings.bundle/Call.plist
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,40 @@
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>Key</key>
<string>call_ringtone_preference</string>
<key>Title</key>
<string>Ringtone</string>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Titles</key>
<array>
<string>Four hands together</string>
<string>It&apos;s a game</string>
<string>Notes of the optimistic</string>
<string>Soft as snow</string>
<string>Leaving a dream</string>
<string>House Keeping</string>
</array>
<key>Values</key>
<array>
<string>four_hands_together.caf</string>
<string>it_s_a_game.caf</string>
<string>notes_of_the_optimistic.caf</string>
<string>soft_as_snow.caf</string>
<string>leaving_a_dream.caf</string>
<string>house_keeping.caf</string>
</array>
</dict>
<dict>
<key>Key</key>
<string>preview_ringtone_button</string>
<key>Title</key>
<string>Listen ringtone</string>
<key>Type</key>
<string>IASKButtonSpecifier</string>
</dict>
</array>
</dict>
</plist>
2 changes: 1 addition & 1 deletion linphone-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2</string>
<string>3</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationExitsOnSuspend</key>
Expand Down
Loading

0 comments on commit 1258240

Please sign in to comment.