From 76aea3660b02189a952cd8cfccc85a8bffbd2986 Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Tue, 22 Apr 2008 16:12:24 -0400
Subject: [PATCH] Add a quick dial button to call the mail box

---
 sflphone-gtk/src/accountwindow.c  | 18 ++++++++++++++++++
 sflphone-gtk/src/calltree.c       | 31 +++++++++++++++++++++++++++++++
 sflphone-gtk/src/configwindow.c   |  1 -
 sflphone-gtk/src/sflphone_const.h |  6 ++++++
 src/account.h                     |  2 ++
 src/managerimpl.cpp               | 15 ++++++++++++++-
 src/user_cfg.h                    |  1 -
 7 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/sflphone-gtk/src/accountwindow.c b/sflphone-gtk/src/accountwindow.c
index 728faedd1a..73edaac47a 100644
--- a/sflphone-gtk/src/accountwindow.c
+++ b/sflphone-gtk/src/accountwindow.c
@@ -43,6 +43,7 @@ GtkWidget * entryUsername;
 GtkWidget * entryPassword;
 GtkWidget * stunServer;
 GtkWidget * stunEnable;
+GtkWidget * entryMailbox;
 
 
 /**
@@ -116,6 +117,7 @@ show_account_window (account_t * a)
   /* TODO: add curProxy, and add boxes for Proxy support */
   gchar * stun_enabled = "FALSE";
   gchar * stun_server= "stun.fwdnet.net:3478";
+  gchar * curMailbox = "888";
 
   // Load from SIP/IAX/Unknown ?
   if(a)
@@ -129,6 +131,7 @@ show_account_window (account_t * a)
       curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_IAX_PASS);
       curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_IAX_USER);
       curFullName = g_hash_table_lookup(currentAccount->properties, ACCOUNT_IAX_FULL_NAME);
+      curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX);
     }
     else if (strcmp(curAccountType, "SIP") == 0) {
       curHostPart = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_HOST_PART);
@@ -138,6 +141,7 @@ show_account_window (account_t * a)
       curUserPart = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_USER_PART);
       stun_enabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_STUN_ENABLED);
       stun_server = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_STUN_SERVER);
+      curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX);
     }
   }
   else
@@ -263,6 +267,14 @@ show_account_window (account_t * a)
   gtk_entry_set_text(GTK_ENTRY(entryPassword), curPassword);
   gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 
+  label = gtk_label_new_with_mnemonic (_("_Mailbox"));
+  gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 10, 11, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+  gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
+  entryMailbox = gtk_entry_new();
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryMailbox);
+  gtk_entry_set_text(GTK_ENTRY(entryMailbox), curMailbox);
+  gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, 10, 11, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+
   // NAT detection code section
   label = gtk_label_new("");
   gtk_label_set_markup(GTK_LABEL( label ),_("<b>NAT Detection</b>"));
@@ -348,6 +360,9 @@ show_account_window (account_t * a)
       g_hash_table_replace(currentAccount->properties, 
 	g_strdup(ACCOUNT_SIP_STUN_ENABLED), 
 	g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stunEnable)) ? "TRUE": "FALSE"));
+      g_hash_table_replace(currentAccount->properties, 
+	g_strdup(ACCOUNT_MAILBOX), 
+	g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox))));
     }
     else if (strcmp(proto, "IAX") == 0) { /* Protocol = IAX */
       g_hash_table_replace(currentAccount->properties, 
@@ -362,6 +377,9 @@ show_account_window (account_t * a)
       g_hash_table_replace(currentAccount->properties, 
 	  g_strdup(ACCOUNT_IAX_PASS), 
 	  g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryPassword))));
+      g_hash_table_replace(currentAccount->properties, 
+	g_strdup(ACCOUNT_MAILBOX), 
+	g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox))));
     }
     else {
 
diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c
index 6806b87d16..2b02150fb3 100644
--- a/sflphone-gtk/src/calltree.c
+++ b/sflphone-gtk/src/calltree.c
@@ -36,6 +36,7 @@ GtkToolItem * holdButton;
 GtkToolItem * transfertButton;
 GtkToolItem * unholdButton;
 GtkToolItem * historyButton;
+GtkToolItem * mailboxButton;
 guint transfertButtonConnId; //The button toggled signal connection ID
 gboolean history_shown;
 
@@ -152,6 +153,26 @@ toggle_history(GtkToggleToolButton *toggle_tool_button,
 	g_signal_emit_by_name(sel, "changed");
 	toolbar_update_buttons();
 }
+
+  static void
+call_mailbox( GtkWidget* widget , gpointer data )
+{
+    account_t* current = account_list_get_current();
+    call_t* mailboxCall = g_new0( call_t , 1);
+    mailboxCall->state = CALL_STATE_DIALING;
+    mailboxCall->from = g_strconcat("\"\" <>", NULL);
+    mailboxCall->callID = g_new0(gchar, 30);
+    g_sprintf(mailboxCall->callID, "%d", rand());
+    //mailboxCall->to = g_strdup(current->mailbox_number);
+    mailboxCall->to = g_strdup("888");
+    mailboxCall->accountID = g_strdup(current->accountID);
+    printf("call : from : %s to %s\n", mailboxCall->from, mailboxCall->to);
+    call_list_add( current_calls , mailboxCall );
+    update_call_tree_add( current_calls , mailboxCall );    
+    update_menus();
+    sflphone_place_call( mailboxCall );
+}
+
 	void 
 toolbar_update_buttons ()
 {
@@ -367,6 +388,16 @@ create_toolbar (){
 	history_shown = FALSE;
 	active_calltree = current_calls;
 
+	//image = gtk_image_new_from_file( ICONS_DIR "/stock_mail-unread.svg");
+	mailboxButton = gtk_toggle_tool_button_new_from_stock( GTK_STOCK_HOME );
+	//gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(mailboxButton), image);
+        gtk_widget_set_tooltip_text(GTK_WIDGET(mailboxButton), _("Mail Box"));
+        gtk_tool_button_set_label(GTK_TOOL_BUTTON(transfertButton), _("Mail Box"));
+        g_signal_connect (G_OBJECT (mailboxButton), "toggled",
+                        G_CALLBACK (call_mailbox), NULL);
+        gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(mailboxButton), -1);
+
+
 	return ret;
 
 }  
diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c
index 4c4f2507bf..13de7c8099 100644
--- a/sflphone-gtk/src/configwindow.c
+++ b/sflphone-gtk/src/configwindow.c
@@ -1223,7 +1223,6 @@ create_general_settings ()
   GtkWidget *notifFrame;
   GtkWidget *notifBox;
   GtkWidget *notifAll;
-  GtkWidget *notifIncoming;
   GtkWidget *notifMails;
 
   GtkWidget *trayFrame;
diff --git a/sflphone-gtk/src/sflphone_const.h b/sflphone-gtk/src/sflphone_const.h
index 9ddd22e2a2..9798fe9b8b 100644
--- a/sflphone-gtk/src/sflphone_const.h
+++ b/sflphone-gtk/src/sflphone_const.h
@@ -36,6 +36,8 @@
 #define ACCOUNT_ALIAS		   "Account.alias"
 /** Tells if account is enabled or not */
 #define ACCOUNT_ENABLED		   "Account.enable"
+/** Mail box number */
+#define ACCOUNT_MAILBOX		   "Account.mailbox"
 /** SIP parameter: full name */
 #define ACCOUNT_SIP_FULL_NAME      "SIP.fullName"
 /** SIP parameter: host name */
@@ -74,6 +76,10 @@
 #define MINIMIZED	      TRUE
 /** Behaviour of the main window on incoming calls */
 #define __POPUP_WINDOW  ( dbus_popup_mode() )
+/** Notification levels */
+#define __NOTIF_LEVEL_MIN     0
+#define __NOTIF_LEVEL_MED     1
+#define __NOTIF_LEVEL_HIGH    2
 
 /** Messages ID for the status bar - Incoming calls */
 #define __MSG_INCOMING_CALL  0 
diff --git a/src/account.h b/src/account.h
index af0a20d7e4..8a820ad015 100644
--- a/src/account.h
+++ b/src/account.h
@@ -43,6 +43,8 @@ typedef std::string AccountID;
 #define CONFIG_ACCOUNT_ENABLE "Account.enable"
 /** Account alias */
 #define CONFIG_ACCOUNT_ALIAS  "Account.alias"
+/** Mail box number */
+#define CONFIG_ACCOUNT_MAILBOX	"Account.mailbox"
 /** IAX paramater : full name */
 #define IAX_FULL_NAME         "IAX.fullName"
 /** IAX paramater : host name */
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 0a21d87d35..d9878bdc0f 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -971,7 +971,6 @@ ManagerImpl::initConfigFile (void)
 
   section = PREFERENCES;
   fill_config_str(ZONE_TONE, DFT_ZONE);
-  fill_config_str(VOICEMAIL_NUM, DFT_VOICEMAIL);
   fill_config_int(CONFIG_ZEROCONF, CONFIG_ZEROCONF_DEFAULT_STR);
   fill_config_int(CONFIG_RINGTONE, YES_STR);
   fill_config_int(CONFIG_DIALPAD, YES_STR);
@@ -1777,6 +1776,12 @@ ManagerImpl::getAccountDetails(const AccountID& accountID)
 	  getConfigString(accountID, SIP_USE_STUN) == "1" ? "TRUE": "FALSE"
 	  )
 	);
+    a.insert(
+	std::pair<std::string, std::string>(
+	  CONFIG_ACCOUNT_MAILBOX, 
+	  getConfigString(accountID, CONFIG_ACCOUNT_MAILBOX)
+	  )
+	);
   }
   else if (accountType == "IAX") {
     a.insert(
@@ -1803,6 +1808,12 @@ ManagerImpl::getAccountDetails(const AccountID& accountID)
 	  getConfigString(accountID, IAX_PASS)
 	  )
 	);
+    a.insert(
+	std::pair<std::string, std::string>(
+	  CONFIG_ACCOUNT_MAILBOX, 
+	  getConfigString(accountID, CONFIG_ACCOUNT_MAILBOX)
+	  )
+	);
   }
   else {
     // Unknown type
@@ -1834,6 +1845,7 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
     setConfig(accountID, SIP_HOST_PART, (*details.find(SIP_HOST_PART)).second);
     //setConfig(accountID, SIP_PROXY,     (*details.find(SIP_PROXY)).second);
     setConfig(accountID, SIP_STUN_SERVER,(*details.find(SIP_STUN_SERVER)).second);
+    setConfig(accountID, CONFIG_ACCOUNT_MAILBOX,(*details.find(CONFIG_ACCOUNT_MAILBOX)).second);
     setConfig(accountID, SIP_USE_STUN,
         (*details.find(SIP_USE_STUN)).second == "TRUE" ? "1" : "0");
   }
@@ -1842,6 +1854,7 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
     setConfig(accountID, IAX_HOST,      (*details.find(IAX_HOST)).second);
     setConfig(accountID, IAX_USER,      (*details.find(IAX_USER)).second);
     setConfig(accountID, IAX_PASS,      (*details.find(IAX_PASS)).second);    
+    setConfig(accountID, CONFIG_ACCOUNT_MAILBOX,(*details.find(CONFIG_ACCOUNT_MAILBOX)).second);
   } else {
     _debug("Unknown account type in setAccountDetails(): %s\n", accountType.c_str());
   }
diff --git a/src/user_cfg.h b/src/user_cfg.h
index 794f4999e1..c32f67c779 100644
--- a/src/user_cfg.h
+++ b/src/user_cfg.h
@@ -51,7 +51,6 @@
 #define CONFIG_NOTIFY		"Notify.all"		  /** Desktop notification level */
 #define CONFIG_MAIL_NOTIFY	"Notify.mails"		  /** Desktop mail notification level */
 #define ZONE_TONE		"Options.zoneToneChoice"  /** Country tone */
-#define VOICEMAIL_NUM		"Options.voicemailNumber" /** Voicemail number */
 #define CONFIG_RINGTONE		"Ringtones.enable"	  /** Ringtones preferences */
 #define CONFIG_START		"Start.hidden"		  /** SFLphone starts in the systm tray or not */
 #define CONFIG_POPUP		"Window.popup"		  /** SFLphone pops up on incoming calls or not */
-- 
GitLab