Commit 3693dd6a authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

History - Set max calls number saved

parent de07d5a9
......@@ -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)
......
......@@ -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
* */
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
......
......@@ -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();
......
......@@ -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>
......
......@@ -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 )
{
......
......@@ -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 );
......
......@@ -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 )
{
......
......@@ -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
......
......@@ -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 */
......
Supports Markdown
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