diff --git a/sflphone-gtk/src/calllist.c b/sflphone-gtk/src/calllist.c index 74dfe8c98c835418ebaefdb337843138deb43bfd..829c3aebd1adae1a0b0071625f218690c89f23bf 100644 --- a/sflphone-gtk/src/calllist.c +++ b/sflphone-gtk/src/calllist.c @@ -26,6 +26,8 @@ * call_t * selectedCall = NULL; */ +guint _HISTORY_MAX_CALLS; + /* GCompareFunc to compare a callID (gchar* and a call_t) */ gint is_callID_callstruct ( gconstpointer a, gconstpointer b) @@ -72,9 +74,30 @@ call_list_clean (calltab_t* tab) void call_list_add (calltab_t* tab, call_t * c) { - g_queue_push_tail (tab->callQueue, (gpointer *) c); + if( tab == history ) + { + g_print("HO HJOH OH HOSDVDBSGDNGNSFHNSGNBADFSVsv\n"); + if( call_list_get_size(tab) < dbus_get_max_calls() ) + { + g_print("SDVDBSGDNGNSFHNSGNBADFSVsv\n"); + g_queue_push_tail (tab->callQueue, (gpointer *) c); + } + } + else + g_queue_push_tail (tab->callQueue, (gpointer *) c); +} + +void +call_history_set_max_calls( gdouble number ) +{ + _HISTORY_MAX_CALLS = number; } +gdouble +call_history_get_max_calls( void ) +{ + return _HISTORY_MAX_CALLS; +} void call_list_remove (calltab_t* tab, const gchar * callID) diff --git a/sflphone-gtk/src/calllist.h b/sflphone-gtk/src/calllist.h index a0381ca12b3f6904d8753ecd479329b5eb2b2463..3a9156aade770053d24dba36fd03beace8162768 100644 --- a/sflphone-gtk/src/calllist.h +++ b/sflphone-gtk/src/calllist.h @@ -70,7 +70,7 @@ typedef struct { gchar * callID; /** The account used to place/receive the call */ gchar * accountID; - /** The information about the calling person. See call_get_name() and call_get_number() +/** The information about the calling person. See call_get_name() and call_get_number() * on how to get the name and number separately. */ gchar * from; /** The number we are calling. Only used when dialing out */ @@ -100,6 +100,12 @@ void call_list_init (calltab_t* tab); /** This function empty and free the call list. */ void call_list_clean (calltab_t* tab); +/** Get the maximun number of calls in the history calltab */ +gdouble call_history_get_max_calls( void ); + +/** Set the maximun number of calls in the history calltab */ +void call_history_set_max_calls( const gdouble number ); + /** This function append a call to list. * @param c The call you want to add * */ diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index cc6b6a894690d18aec2667f009c44e6b32271d25..2ef2a24b0a125f2c6e1b5d51914de27917764239 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -619,6 +619,9 @@ update_call_tree (calltab_t* tab, call_t * c) void update_call_tree_add (calltab_t* tab, call_t * c) { + if( tab == history && ( call_list_get_size( tab ) >= dbus_get_max_calls() ) ) + return; + GdkPixbuf *pixbuf; GtkTreeIter iter; GtkTreeSelection* sel; diff --git a/sflphone-gtk/src/configurationmanager-glue.h b/sflphone-gtk/src/configurationmanager-glue.h index f25ab3f7fb677e8cbdfe52f07c9d96a79c21186c..0e6e472fd57a3b46061bd43cce7fb52893bab6ab 100644 --- a/sflphone-gtk/src/configurationmanager-glue.h +++ b/sflphone-gtk/src/configurationmanager-glue.h @@ -1481,6 +1481,81 @@ static inline #endif gboolean +org_sflphone_SFLphone_ConfigurationManager_get_max_calls (DBusGProxy *proxy, gdouble* OUT_calls, GError **error) + +{ + return dbus_g_proxy_call (proxy, "getMaxCalls", error, G_TYPE_INVALID, G_TYPE_DOUBLE, OUT_calls, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_max_calls_reply) (DBusGProxy *proxy, gdouble OUT_calls, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_get_max_calls_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gdouble OUT_calls; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_DOUBLE, &OUT_calls, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_max_calls_reply)data->cb) (proxy, OUT_calls, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_get_max_calls_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_max_calls_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "getMaxCalls", org_sflphone_SFLphone_ConfigurationManager_get_max_calls_async_callback, stuff, g_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_ConfigurationManager_set_max_calls (DBusGProxy *proxy, const gdouble IN_calls, GError **error) + +{ + return dbus_g_proxy_call (proxy, "setMaxCalls", error, G_TYPE_DOUBLE, IN_calls, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_max_calls_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_set_max_calls_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_set_max_calls_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_set_max_calls_async (DBusGProxy *proxy, const gdouble IN_calls, org_sflphone_SFLphone_ConfigurationManager_set_max_calls_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setMaxCalls", org_sflphone_SFLphone_ConfigurationManager_set_max_calls_async_callback, stuff, g_free, G_TYPE_DOUBLE, IN_calls, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean org_sflphone_SFLphone_ConfigurationManager_start_hidden (DBusGProxy *proxy, GError **error) { diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index 06713faf1af24efc312a022b7843f18fe7313195..897b2b31efa458a0448cc00502de28bee3c45f7b 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -523,6 +523,12 @@ set_mail_notif( ) dbus_set_mail_notify( ); } +void +update_max_value( GtkRange* scale ) +{ + dbus_set_max_calls(gtk_range_get_value( GTK_RANGE( scale ))); +} + void ringtone_enabled( void ) { @@ -1229,6 +1235,11 @@ create_general_settings () GtkWidget *trayBox; GtkWidget *trayItem; + GtkWidget *historyFrame; + GtkWidget *historyBox; + GtkWidget *value; + GtkWidget *label; + // Main widget ret = gtk_vbox_new(FALSE, 10); gtk_container_set_border_width(GTK_CONTAINER(ret), 10); @@ -1277,7 +1288,29 @@ create_general_settings () gtk_box_pack_start( GTK_BOX(trayBox) , trayItem , TRUE , TRUE , 1); g_signal_connect(G_OBJECT( trayItem ) , "clicked" , G_CALLBACK( start_hidden ) , NULL); + historyFrame = gtk_frame_new(_("Calls History")); + gtk_box_pack_start(GTK_BOX(ret), historyFrame, FALSE, FALSE, 0); + gtk_widget_show( historyFrame ); + + historyBox = gtk_vbox_new(FALSE, 10); + gtk_box_pack_start(GTK_BOX(historyFrame), historyBox, TRUE, TRUE, 0); + gtk_widget_show( historyBox ); + gtk_container_add( GTK_CONTAINER(historyFrame) , historyBox); + + label = gtk_label_new_with_mnemonic(_("Maximum calls")); + gtk_box_pack_start( GTK_BOX(historyBox) , label , TRUE , TRUE , 0); + + value = gtk_hscale_new_with_range(0.0 , 50.0 , 1.0); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), value); + gtk_scale_set_digits( GTK_SCALE(value) , 0); + gtk_scale_set_value_pos( GTK_SCALE(value) , GTK_POS_RIGHT); + gtk_range_set_value( GTK_RANGE( value ) , dbus_get_max_calls()); + gtk_box_pack_start( GTK_BOX(historyBox) , value , TRUE , TRUE , 0); + + g_signal_connect( G_OBJECT( value) , "value-changed" , G_CALLBACK( update_max_value ) , NULL); + gtk_widget_show_all(ret); + return ret; } diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index c506d2ca8a020d5d14311c921a3413c71ad7145c..b6e873e48e8f2eae8ffe7e262cfb68b217cf68fa 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -1192,7 +1192,6 @@ dbus_set_volume_controls( ) org_sflphone_SFLphone_ConfigurationManager_set_volume_controls( configurationManagerProxy, &error); - g_print("After"); if(error) { g_error_free(error); @@ -1201,6 +1200,40 @@ dbus_set_volume_controls( ) g_print("DBus called set_volume_controls on ConfigurationManager\n"); } +void +dbus_set_max_calls( const gdouble calls ) +{ + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_max_calls( + configurationManagerProxy, + calls, + &error); + if(error) + { + g_error_free(error); + } + else + g_print("DBus called set_max_calls on ConfigurationManager\n"); +} + +gdouble +dbus_get_max_calls( void ) +{ + GError* error = NULL; + gdouble calls; + org_sflphone_SFLphone_ConfigurationManager_get_max_calls( + configurationManagerProxy, + &calls, + &error); + if(error) + { + g_error_free(error); + } + else + g_print("DBus called get_max_calls on ConfigurationManager\n"); + return calls; +} + void dbus_start_hidden( void ) { @@ -1208,7 +1241,6 @@ dbus_start_hidden( void ) org_sflphone_SFLphone_ConfigurationManager_start_hidden( configurationManagerProxy, &error); - g_print("After"); if(error) { g_error_free(error); diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index 7e239b6cafa078506e05f58d26843b505d957faa..32bb1ebea1379f210bca6a17e20f1be4e598e60b 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -309,6 +309,16 @@ int dbus_get_volume_controls( void ); */ void dbus_start_hidden( void ); +/** + * ConfigurationManager - Gives the maximum number of calls the user wants to have in the history + * @return double The maximum number of calls + */ +gdouble dbus_get_max_calls( void ); + +/** + * ConfigurationManager - Gives the maximum number of calls the user wants to have in the history + */ +void dbus_set_max_calls( const gdouble calls ); /** * ConfigurationManager - Configure the start-up option * @return int 1 if SFLphone should start in the system tray diff --git a/src/dbus/configurationmanager-glue.h b/src/dbus/configurationmanager-glue.h index 15308ae69184a6bc6b0484b8eb61c78f3c0913ba..7f01f326fb52d20faa17c7da6355053516e5f018 100644 --- a/src/dbus/configurationmanager-glue.h +++ b/src/dbus/configurationmanager-glue.h @@ -59,6 +59,8 @@ public: register_method(ConfigurationManager, setDialpad, _setDialpad_stub); register_method(ConfigurationManager, getVolumeControls, _getVolumeControls_stub); register_method(ConfigurationManager, setVolumeControls, _setVolumeControls_stub); + register_method(ConfigurationManager, getMaxCalls, _getMaxCalls_stub); + register_method(ConfigurationManager, setMaxCalls, _setMaxCalls_stub); register_method(ConfigurationManager, startHidden, _startHidden_stub); register_method(ConfigurationManager, isStartHidden, _isStartHidden_stub); register_method(ConfigurationManager, popupMode, _popupMode_stub); @@ -262,6 +264,16 @@ public: { { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument getMaxCalls_args[] = + { + { "calls", "d", false }, + { 0, 0, 0 } + }; + static ::DBus::IntrospectedArgument setMaxCalls_args[] = + { + { "calls", "d", true }, + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument startHidden_args[] = { { 0, 0, 0 } @@ -335,6 +347,8 @@ public: { "setDialpad", setDialpad_args }, { "getVolumeControls", getVolumeControls_args }, { "setVolumeControls", setVolumeControls_args }, + { "getMaxCalls", getMaxCalls_args }, + { "setMaxCalls", setMaxCalls_args }, { "startHidden", startHidden_args }, { "isStartHidden", isStartHidden_args }, { "popupMode", popupMode_args }, @@ -412,6 +426,8 @@ public: virtual void setDialpad( ) = 0; virtual ::DBus::Int32 getVolumeControls( ) = 0; virtual void setVolumeControls( ) = 0; + virtual ::DBus::Double getMaxCalls( ) = 0; + virtual void setMaxCalls( const ::DBus::Double& calls ) = 0; virtual void startHidden( ) = 0; virtual ::DBus::Int32 isStartHidden( ) = 0; virtual ::DBus::Int32 popupMode( ) = 0; @@ -820,6 +836,25 @@ private: ::DBus::ReturnMessage reply(call); return reply; } + ::DBus::Message _getMaxCalls_stub( const ::DBus::CallMessage& call ) + { + ::DBus::MessageIter ri = call.reader(); + + ::DBus::Double argout1 = getMaxCalls(); + ::DBus::ReturnMessage reply(call); + ::DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; + } + ::DBus::Message _setMaxCalls_stub( const ::DBus::CallMessage& call ) + { + ::DBus::MessageIter ri = call.reader(); + + ::DBus::Double argin1; ri >> argin1; + setMaxCalls(argin1); + ::DBus::ReturnMessage reply(call); + return reply; + } ::DBus::Message _startHidden_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); diff --git a/src/dbus/configurationmanager-introspec.xml b/src/dbus/configurationmanager-introspec.xml index 04be4c40c4b1ad72b87ec58513b3eb5af499e1d9..d5d4bfde603bd13b345c44b5db92b4238d1488c8 100644 --- a/src/dbus/configurationmanager-introspec.xml +++ b/src/dbus/configurationmanager-introspec.xml @@ -166,6 +166,14 @@ <method name="setVolumeControls"> </method> + <method name="getMaxCalls"> + <arg type="d" name="calls" direction="out"/> + </method> + + <method name="setMaxCalls"> + <arg type="d" name="calls" direction="in"/> + </method> + <method name="startHidden"> </method> diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp index 0e240ce51df6f69a2cdfbb0154010dd505de3296..d15d70d03363529ef47376404d28cfd0a37aeb40 100644 --- a/src/dbus/configurationmanager.cpp +++ b/src/dbus/configurationmanager.cpp @@ -273,6 +273,18 @@ ConfigurationManager::setVolumeControls( void ) Manager::instance().setVolumeControls( ); } +::DBus::Double +ConfigurationManager::getMaxCalls( void ) +{ + return Manager::instance().getMaxCalls( ); +} + +void +ConfigurationManager::setMaxCalls( const ::DBus::Double& calls ) +{ + Manager::instance().setMaxCalls( calls ); +} + void ConfigurationManager::startHidden( void ) { diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index 170b9ee59489b04628ce9645c1cc0c32679fb57b..9da736e71c6fff844cd7ebf7495553c69403dc5d 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -77,6 +77,8 @@ public: void setRingtoneChoice( const ::DBus::String& tone ); ::DBus::Int32 getDialpad( void ); void setDialpad( void ); + void setMaxCalls( const ::DBus::Double& calls); + ::DBus::Double getMaxCalls( void ); ::DBus::Int32 getVolumeControls( void ); void setVolumeControls( void ); ::DBus::Int32 isStartHidden( void ); diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index a46804dea103f95629d61763a22acf6798ca1b0f..08d84283a0a1439a2a5a59591ee294fc4dff285a 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -979,6 +979,7 @@ ManagerImpl::initConfigFile (void) fill_config_int(CONFIG_NOTIFY , YES_STR); fill_config_int(CONFIG_MAIL_NOTIFY , NO_STR); fill_config_int(CONFIG_VOLUME , YES_STR); + fill_config_int(CONFIG_HISTORY , DFT_MAX_CALLS); // Loads config from ~/.sflphone/sflphonedrc or so.. if (createSettingsPath() == 1) { @@ -1353,6 +1354,19 @@ ManagerImpl::switchPopupMode( void ) ( getConfigInt( PREFERENCES , CONFIG_POPUP ) == WINDOW_POPUP)? setConfig(PREFERENCES , CONFIG_POPUP , NO_STR ) : setConfig( PREFERENCES , CONFIG_POPUP , YES_STR ); } +void +ManagerImpl::setMaxCalls( const double& calls ) +{ + setConfig( PREFERENCES , CONFIG_HISTORY , (int)calls ); +} + +double +ManagerImpl::getMaxCalls( void ) +{ + _debug("a;kvnsnblsb %i\n" , getConfigInt( PREFERENCES , CONFIG_HISTORY )); + return getConfigInt( PREFERENCES , CONFIG_HISTORY ); +} + int ManagerImpl::popupMode( void ) { diff --git a/src/managerimpl.h b/src/managerimpl.h index 51078abb19a5e894ad621f2ca23359143f598ada..f4f057be270ffb8cdcc7dd675dd6bc962b8f0f85 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -480,6 +480,18 @@ class ManagerImpl { */ void setVolumeControls( void ); + /** + * Set the maximum number of calls to keep in the history + * @param calls The number of calls + */ + void setMaxCalls( const double& calls ); + + /** + * Get the maximum number of calls to keep in the history + * @return double The number of calls + */ + double getMaxCalls( void ); + /** * Configure the start-up option * @return int 1 if SFLphone should start in the system tray diff --git a/src/user_cfg.h b/src/user_cfg.h index 3c0c9d323703c8101e1aa77a5bb2d7a9acbf2417..173a6693374e0b055ba54f245610993f8e52bb22 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -48,6 +48,7 @@ #define PREFERENCES "Preferences" /** Section Preferences */ #define CONFIG_DIALPAD "Dialpad.display" /** Display dialpad preferences */ +#define CONFIG_HISTORY "History.maxCalls" /** Set the maximum number of calls kept */ #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 */ @@ -79,6 +80,7 @@ #define DFT_FRAME_SIZE "20" /** Default frame size in millisecond */ #define DFT_SAMPLE_RATE "44100" /** Default sample rate in HZ */ #define DFT_NOTIF_LEVEL "2" /** Default desktop notification level : maximum */ +#define DFT_MAX_CALLS "20" /** Default maximum calls in history */ #ifdef USE_ZEROCONF #define CONFIG_ZEROCONF_DEFAULT_STR "1" /** Default Zero configuration networking module value */