Commit 610afd58 authored by Sylvain Berfini's avatar Sylvain Berfini

Try to prevent other crash reported

parent 26f75372
......@@ -292,6 +292,13 @@ namespace Linphone.Model
string host, token;
host = ((App)App.Current).PushChannelUri.Host;
token = ((App)App.Current).PushChannelUri.AbsolutePath;
if (host == null || token == null)
{
Logger.Warn("Can't set the PN params: {0} {1}", host, token);
return;
}
if (Customs.AddPasswordInContactsParams)
{
SIPAccountSettingsManager sip = new SIPAccountSettingsManager();
......@@ -751,7 +758,7 @@ namespace Linphone.Model
if (BasePage.StatusBar != null)
BasePage.StatusBar.RefreshStatus(state);
}
catch (Exception) { }
catch { }
});
}
......@@ -898,21 +905,28 @@ namespace Linphone.Model
private void LookupForContact(LinphoneCall call)
{
string sipAddress = call.GetRemoteAddress().AsStringUriOnly();
if (call.GetRemoteAddress().GetDisplayName().Length == 0)
try
{
if (sipAddress.StartsWith("sip:"))
string sipAddress = call.GetRemoteAddress().AsStringUriOnly();
if (call.GetRemoteAddress().GetDisplayName().Length == 0)
{
sipAddress = sipAddress.Substring(4);
}
Logger.Msg("[LinphoneManager] Display name null, looking for remote address in contact: " + sipAddress);
if (sipAddress.StartsWith("sip:"))
{
sipAddress = sipAddress.Substring(4);
}
Logger.Msg("[LinphoneManager] Display name null, looking for remote address in contact: " + sipAddress);
ContactManager.ContactFound += OnContactFound;
ContactManager.FindContact(sipAddress);
ContactManager.ContactFound += OnContactFound;
ContactManager.FindContact(sipAddress);
}
else
{
Logger.Msg("[LinphoneManager] Display name found: " + call.GetRemoteAddress().GetDisplayName());
}
}
else
catch
{
Logger.Msg("[LinphoneManager] Display name found: " + call.GetRemoteAddress().GetDisplayName());
Logger.Warn("[LinphoneManager] Execption occured while looking for contact...");
}
}
......
......@@ -202,21 +202,28 @@ namespace Linphone.Model
{
if (ValueChanged(LogLevelKeyName))
{
Config.SetInt(ApplicationSection, LogLevelKeyName, Convert.ToInt32(GetNew(LogLevelKeyName)));
LinphoneManager.Instance.ConfigureLogger();
if ((Get(LogDestinationKeyName) == OutputTraceDest.File.ToString())
&& (GetNew(LogLevelKeyName) == ((int)OutputTraceLevel.None).ToString()))
try
{
try
Config.SetInt(ApplicationSection, LogLevelKeyName, Convert.ToInt32(GetNew(LogLevelKeyName)));
LinphoneManager.Instance.ConfigureLogger();
if ((Get(LogDestinationKeyName) == OutputTraceDest.File.ToString())
&& (GetNew(LogLevelKeyName) == ((int)OutputTraceLevel.None).ToString()))
{
StorageFile logfile = await ApplicationData.Current.LocalFolder.GetFileAsync(Get(LogOptionKeyName));
await logfile.DeleteAsync();
}
catch
{
Logger.Warn("Failed deleting log file {0}", Get(LogOptionKeyName));
try
{
StorageFile logfile = await ApplicationData.Current.LocalFolder.GetFileAsync(Get(LogOptionKeyName));
await logfile.DeleteAsync();
}
catch
{
Logger.Warn("Failed deleting log file {0}", Get(LogOptionKeyName));
}
}
}
catch
{
Logger.Warn("Failed setting the log level name {0}", Get(LogLevelKeyName));
}
}
}
#endregion
......@@ -1125,7 +1132,28 @@ namespace Linphone.Model
if (ValueChanged(SIPTransportSettingKeyName))
{
Transports transports = LinphoneManager.Instance.LinphoneCoreFactory.CreateTransports();
int port = Convert.ToInt32(GetNew(SIPPortKeyName));
int port;
try
{
port = Convert.ToInt32(GetNew(SIPPortKeyName));
}
catch
{
port = 5060;
if (transports.UDP > 0)
{
port = transports.UDP;
}
else if (transports.TCP > 0)
{
port = transports.TCP;
}
else if (transports.TLS > 0)
{
port = transports.TLS;
}
}
if (GetNew(SIPTransportSettingKeyName) == AppResources.TransportUDP)
{
transports.UDP = port;
......
......@@ -237,6 +237,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Can&apos;t create chat room for this SIP address, please check it is valid..
/// </summary>
public static string ChatRoomCreationError {
get {
return ResourceManager.GetString("ChatRoomCreationError", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Close.
/// </summary>
......@@ -552,6 +561,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Error.
/// </summary>
public static string GenericError {
get {
return ResourceManager.GetString("GenericError", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to GSM.
/// </summary>
......@@ -660,6 +678,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to The SIP address you provided is incorrect. Please ensure it matches the format username@domain..
/// </summary>
public static string InvalidSipAddressError {
get {
return ResourceManager.GetString("InvalidSipAddressError", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use linphone.org account.
/// </summary>
......
......@@ -522,4 +522,13 @@ Do you want to report it to the developpers ? It will help fix it faster.</value
<data name="DeleteLogs" xml:space="preserve">
<value>Delete logs file</value>
</data>
<data name="ChatRoomCreationError" xml:space="preserve">
<value>Can't create chat room for this SIP address, please check it is valid.</value>
</data>
<data name="GenericError" xml:space="preserve">
<value>Error</value>
</data>
<data name="InvalidSipAddressError" xml:space="preserve">
<value>The SIP address you provided is incorrect. Please ensure it matches the format username@domain.</value>
</data>
</root>
\ No newline at end of file
......@@ -355,6 +355,11 @@ namespace Linphone.Views
LinphoneProxyConfig config = LinphoneManager.Instance.LinphoneCore.GetProxyConfigList()[0] as LinphoneProxyConfig;
sipAddress += "@" + config.GetDomain();
}
else
{
System.Windows.MessageBox.Show(AppResources.InvalidSipAddressError, AppResources.GenericError, MessageBoxButton.OK);
return;
}
}
ContactManager.Instance.FindContact(sipAddress);
......@@ -362,23 +367,38 @@ namespace Linphone.Views
ContactName.Visibility = Visibility.Visible;
NewChat.Visibility = Visibility.Collapsed;
chatRoom = LinphoneManager.Instance.LinphoneCore.CreateChatRoom(sipAddress);
try
{
chatRoom = LinphoneManager.Instance.LinphoneCore.CreateChatRoom(sipAddress);
if (DatabaseManager.Instance.Messages.Count(m => m.LocalContact.Equals(sipAddress) || m.RemoteContact.Equals(sipAddress)) > 0)
if (DatabaseManager.Instance.Messages.Count(m => m.LocalContact.Equals(sipAddress) || m.RemoteContact.Equals(sipAddress)) > 0)
{
// Define the query to gather all of the messages linked to the current contact.
var messagesInDB = from message in DatabaseManager.Instance.Messages where (message.LocalContact.Equals(sipAddress) || message.RemoteContact.Equals(sipAddress)) select message;
// Execute the query and place the results into a collection.
List<ChatMessage> messages = messagesInDB.ToList();
DisplayPastMessages(messages);
}
}
catch
{
// Define the query to gather all of the messages linked to the current contact.
var messagesInDB = from message in DatabaseManager.Instance.Messages where (message.LocalContact.Equals(sipAddress) || message.RemoteContact.Equals(sipAddress)) select message;
// Execute the query and place the results into a collection.
List<ChatMessage> messages = messagesInDB.ToList();
DisplayPastMessages(messages);
Logger.Err("Can't create chat room for sip address {0}", sipAddress);
throw;
}
}
if (MessageBox.Text != null && MessageBox.Text.Length > 0)
if (chatRoom != null)
{
if (MessageBox.Text != null && MessageBox.Text.Length > 0)
{
SendMessage(MessageBox.Text);
}
MessageBox.Reset();
}
else
{
SendMessage(MessageBox.Text);
System.Windows.MessageBox.Show(AppResources.ChatRoomCreationError, AppResources.GenericError, MessageBoxButton.OK);
}
MessageBox.Reset();
}
}
......
......@@ -134,8 +134,16 @@ namespace Linphone.Views
private void speaker_Click_1(object sender, RoutedEventArgs e)
{
bool isSpeakerToggled = (bool)speaker.IsChecked;
speakerImg.Source = new BitmapImage(new Uri(isSpeakerToggled ? speakerOn : speakerOff, UriKind.RelativeOrAbsolute));
LinphoneManager.Instance.EnableSpeaker(isSpeakerToggled);
try
{
LinphoneManager.Instance.EnableSpeaker(isSpeakerToggled);
speakerImg.Source = new BitmapImage(new Uri(isSpeakerToggled ? speakerOn : speakerOff, UriKind.RelativeOrAbsolute));
}
catch
{
Logger.Warn("Exception while trying to toggle speaker to {0}", isSpeakerToggled.ToString());
speaker.IsChecked = !isSpeakerToggled;
}
}
private void microphone_Click_1(object sender, RoutedEventArgs e)
......@@ -272,7 +280,13 @@ namespace Linphone.Views
LinphoneCallParams param = call.GetCurrentParamsCopy();
Status.Text = mm.ToString("00") + ":" + ss.ToString("00");
LinphoneCallStats audioStats = call.GetAudioStats();
LinphoneCallStats audioStats = null;
try
{
audioStats = call.GetAudioStats();
}
catch { }
if (audioStats != null)
{
AudioDownBw.Text = String.Format(AppResources.StatDownloadBW + ": {0:0.00} kb/s", audioStats.GetDownloadBandwidth());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment