phonemgr r310 - in trunk: . libgsm
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: phonemgr r310 - in trunk: . libgsm
- Date: Wed, 18 Jun 2008 14:40:28 +0000 (UTC)
Author: hadess
Date: Wed Jun 18 14:40:27 2008
New Revision: 310
URL: http://svn.gnome.org/viewvc/phonemgr?rev=310&view=rev
Log:
2008-06-18 Bastien Nocera <hadess hadess net>
* libgsm/glibgsmtest.c (main): Add support for setting the type
of data required on the command-line
* libgsm/phonemgr-listener.c
(phonemgr_listener_set_cell_notification): Fix valgrind warning
(phonemgr_listener_get_data), (phonemgr_listener_list_all_data):
Add start of support for CALENDAR data in list_all_data, fix
spurious mutex unlock in the get_data code
* libgsm/phonemgr-utils.c (phonemgr_utils_connect): Fix some
more valgrind warnings
Modified:
trunk/ChangeLog
trunk/libgsm/glibgsmtest.c
trunk/libgsm/phonemgr-listener.c
trunk/libgsm/phonemgr-utils.c
Modified: trunk/libgsm/glibgsmtest.c
==============================================================================
--- trunk/libgsm/glibgsmtest.c (original)
+++ trunk/libgsm/glibgsmtest.c Wed Jun 18 14:40:27 2008
@@ -104,6 +104,7 @@
static const char *put_card = NULL;
static gboolean send_test_msg = FALSE;
static const char *bdaddr = NULL;
+static const char *data_type = NULL;
static const GOptionEntry entries[] = {
{ "address", 'a', 0, G_OPTION_ARG_STRING, &bdaddr, "Address of the device to connect to", NULL },
@@ -112,6 +113,7 @@
{ "get-data", 'g', 0, G_OPTION_ARG_STRING, &get_uuid, "Retrieve the PIM data with the given UUID", NULL },
{ "delete-data", 'd', 0, G_OPTION_ARG_STRING, &delete_uuid, "Delete the PIM data with the given UUID", NULL },
{ "put-data", 'p', 0, G_OPTION_ARG_FILENAME, &put_card, "Upload the given vCard file", NULL },
+ { "type", 't', 0, G_OPTION_ARG_STRING, &data_type, "Data type for the above functions. One of \"contact\", \"calendar\" and \"todo\"", NULL },
{ "send-msg", 's', 0, G_OPTION_ARG_NONE, &send_test_msg, "Send a test message", NULL },
{ NULL }
};
@@ -123,6 +125,7 @@
GOptionContext *context;
GError *err = NULL;
PhonemgrListener *listener;
+ PhonemgrListenerDataType type;
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
@@ -161,6 +164,24 @@
return 1;
}
+ /* An action? Get the data type */
+ if (list_all != FALSE || get_uuid != NULL || put_card != NULL || delete_uuid != NULL) {
+ if (data_type == NULL) {
+ g_print ("Please use --type to pass a type of data to manipulate\n");
+ return 1;
+ }
+ if (g_str_equal (data_type, "contact") != FALSE) {
+ type = PHONEMGR_LISTENER_DATA_CONTACT;
+ } else if (g_str_equal (data_type, "calendar") != FALSE) {
+ type = PHONEMGR_LISTENER_DATA_CALENDAR;
+ } else if (g_str_equal (data_type, "todo") != FALSE) {
+ type = PHONEMGR_LISTENER_DATA_TODO;
+ } else {
+ g_print ("Invalid data type passed. It must be one of \"contact\", \"calendar\" and \"todo\"\n");
+ return 1;
+ }
+ }
+
if (phonemgr_listener_connect (listener, bdaddr, &err)) {
g_message ("Connected OK");
@@ -172,26 +193,20 @@
char **array;
guint i;
- array = phonemgr_listener_list_all_data (listener, PHONEMGR_LISTENER_DATA_CONTACT);
+ g_message ("listing all data of type %d", type);
+ array = phonemgr_listener_list_all_data (listener, type);
if (array == NULL) {
g_message ("BLEEEEEEH");
return 1;
}
- for (i = 0; array[i] != NULL; i++) {
- char *vcard;
-
- vcard = phonemgr_listener_get_data (listener, PHONEMGR_LISTENER_DATA_CONTACT, array[i]);
- if (vcard != NULL) {
- g_print ("UUID: %s\n", array[i]);
- g_print ("%s\n", vcard);
- }
- }
+ for (i = 0; array[i] != NULL; i++)
+ g_print ("UUID: %s\n", array[i]);
g_strfreev (array);
} else if (get_uuid != NULL) {
char *vcard;
- vcard = phonemgr_listener_get_data (listener, PHONEMGR_LISTENER_DATA_CONTACT, get_uuid);
+ vcard = phonemgr_listener_get_data (listener, type, get_uuid);
if (vcard != NULL) {
g_print ("%s\n", vcard);
g_free (vcard);
@@ -208,7 +223,7 @@
return 1;
}
- uuid = phonemgr_listener_put_data (listener, PHONEMGR_LISTENER_DATA_CONTACT, contents);
+ uuid = phonemgr_listener_put_data (listener, type, contents);
if (uuid != NULL) {
g_print ("Added vCard at location '%s'\n", uuid);
g_free (uuid);
@@ -216,7 +231,7 @@
g_message ("Failed to add data from '%s' to the device", put_card);
}
} else if (delete_uuid != NULL) {
- phonemgr_listener_delete_data (listener, PHONEMGR_LISTENER_DATA_CONTACT, delete_uuid);
+ phonemgr_listener_delete_data (listener, type, delete_uuid);
} else {
g_message ("Nothing to do!");
}
Modified: trunk/libgsm/phonemgr-listener.c
==============================================================================
--- trunk/libgsm/phonemgr-listener.c (original)
+++ trunk/libgsm/phonemgr-listener.c Wed Jun 18 14:40:27 2008
@@ -931,6 +931,7 @@
/* Set up cell notification using GN_OP_GetNetworkInfo */
gn_data_clear (&l->phone_state->data);
+ memset (&info, 0, sizeof(info));
l->phone_state->data.network_info = &info;
l->phone_state->data.reg_notification = phonemgr_listener_cell_not_cb;
l->phone_state->data.callback_data = l;
@@ -1254,6 +1255,11 @@
}
break;
case PHONEMGR_LISTENER_DATA_CALENDAR:
+ {
+ gn_calnote_list calnote_list;
+ gn_calnote calnote;
+
+ }
break;
case PHONEMGR_LISTENER_DATA_TODO:
break;
@@ -1314,7 +1320,6 @@
for (i = 1, found = 0; found <= memstat.used; i++) {
gn_phonebook_entry entry;
if (phonemgr_listener_get_phonebook_entry (l, memstat.memory_type, i, &entry) == FALSE) {
- g_mutex_unlock (l->mutex);
break;
} else if (entry.empty == FALSE) {
char *uuid;
@@ -1329,6 +1334,41 @@
return (char **) g_ptr_array_free (a, FALSE);
}
case PHONEMGR_LISTENER_DATA_CALENDAR:
+ {
+ GPtrArray *a;
+ gn_calnote_list calnote_list;
+ gn_calnote calnote;
+ gn_error error;
+ guint i;
+
+ g_mutex_lock (l->mutex);
+
+ memset (&calnote, 0, sizeof (calnote));
+ memset (&calnote_list, 0, sizeof (calnote_list));
+ l->phone_state->data.calnote = &calnote;
+ l->phone_state->data.calnote_list = &calnote_list;
+
+ a = g_ptr_array_new ();
+
+ for (i = 0; i < INT_MAX; i++) {
+ calnote.location = i;
+ error = phonemgr_listener_gnokii_func (GN_OP_GetCalendarNote, l);
+ if (error != GN_ERR_NONE) {
+ if (error == GN_ERR_EMPTYLOCATION || error == GN_ERR_INVALIDLOCATION)
+ continue;
+ break;
+ } else {
+ char *uuid;
+ uuid = g_strdup_printf ("GPM-UUID-%s-%d", l->imei, i);
+ g_ptr_array_add (a, uuid);
+ }
+ }
+
+ g_ptr_array_add (a, NULL);
+ g_mutex_unlock (l->mutex);
+
+ return (char **) g_ptr_array_free (a, FALSE);
+ }
break;
case PHONEMGR_LISTENER_DATA_TODO:
break;
Modified: trunk/libgsm/phonemgr-utils.c
==============================================================================
--- trunk/libgsm/phonemgr-utils.c (original)
+++ trunk/libgsm/phonemgr-utils.c Wed Jun 18 14:40:27 2008
@@ -532,6 +532,7 @@
}
g_strfreev (lines);
+ memset (&data, 0, sizeof (data));
phonemgr_utils_gn_statemachine_clear (&state);
if (gn_cfg_phone_load("", &state) < 0) {
@@ -547,7 +548,7 @@
return NULL;
}
- phone_state = g_new (PhonemgrState, 1);
+ phone_state = g_new0 (PhonemgrState, 1);
phone_state->data = data;
phone_state->state = state;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]