[pkg-fso-commits] [SCM] libframeworkd-phonegui branch, upstream, updated. 640da47bfcff755388d0fb8f443eb34e0dea3c72

Didier 'Ptitjes ptitjes at free.fr
Sat Dec 27 20:50:05 UTC 2008


The following commit has been merged in the upstream branch:
commit 1ff473a98ec15842da2043894b52d1712d0b3d38
Merge: 37129dcfbe7ff04e5c11b94655df0e3c8c7ff412 5b4f270c066b604457e78e8e37f2211e73cec134
Author: Didier 'Ptitjes <ptitjes at free.fr>
Date:   Sat Dec 6 12:14:40 2008 +0100

    Merge branch 'master' of git at shr.bearstech.com:shr
    
    Conflicts:
    
    	ophonekitd/src/ophonekitd-main.c
    
    Signed-off-by: Didier 'Ptitjes <ptitjes at free.fr>

diff --combined ophonekitd/src/ophonekitd-main.c
index 4da120d,fabaf93..956f0ef
--- a/ophonekitd/src/ophonekitd-main.c
+++ b/ophonekitd/src/ophonekitd-main.c
@@@ -21,6 -21,8 +21,8 @@@
  #include <string.h>
  #include <dbus/dbus-glib.h>
  #include <dbus/dbus-glib-bindings.h>
+ #include <glib.h>
+ #include <glib/gthread.h>
  #include <frameworkd-glib/frameworkd-glib-dbus.h>
  #include <frameworkd-glib/ogsmd/frameworkd-glib-ogsmd-dbus.h>
  #include <frameworkd-glib/ogsmd/frameworkd-glib-ogsmd-call.h>
@@@ -31,24 -33,20 +33,26 @@@
  #include <frameworkd-glib/odeviced/frameworkd-glib-odeviced-idlenotifier.h>
  #include <frameworkd-glib/odeviced/frameworkd-glib-odeviced-powersupply.h>
  #include <frameworkd-glib/odeviced/frameworkd-glib-odeviced-audio.h>
- 
  #include "ophonekitd-phonegui.h"
 +#include "ophonekitd-phonelog.h"
+ #include "ophonekitd-dbus.h"
  
 +typedef struct {
 +	int id;
 +	int unique_id;
 +} call_t;
 +
  gboolean sim_auth_active = FALSE;
 -int *incoming_calls = NULL;
 -int *outgoing_calls = NULL;
 +call_t *incoming_calls = NULL;
 +call_t *outgoing_calls = NULL;
  int incoming_calls_size = 0;
  int outgoing_calls_size = 0;
  
  int main(int argc, char ** argv) {
      GMainLoop *mainloop = NULL;
      FrameworkdHandlers fwHandler;
+     DBusGConnection *bus = NULL;
+     DBusGProxy *bus_proxy = NULL;
  
      /* Load, connect and initiate phonegui library */
      phonegui_load("ophonekitd");
@@@ -56,10 -54,6 +60,10 @@@
      phonegui_init(argc, argv, exit_callback);
      g_debug("Phonegui initiated");
  
 +    /* Initiate phonelog database */
 +    phonelog_init_database();
 +    g_debug("Phonelog database initiated");
 +
      /* Register dbus handlers */
      fwHandler.networkStatus = NULL;
      fwHandler.networkSignalStrength = NULL;
@@@ -67,14 -61,21 +71,21 @@@
      fwHandler.simIncomingStoredMessage = ophonekitd_sim_incoming_stored_message_handler;
      fwHandler.callCallStatus = ophonekitd_call_status_handler;
      fwHandler.deviceIdleNotifierState = ophonekitd_device_idle_notifier_state_handler;
-     dbus_connect_to_bus(&fwHandler);
-     g_debug("Connected to the buses");
  
-     /* Initiate glib main loop */
-     g_type_init();
+     if (!g_thread_supported ())
+         g_thread_init (NULL);
+ 
+     dbus_g_thread_init ();
+ 
+     
      mainloop = g_main_loop_new (NULL, FALSE);
      g_debug("Entering glib main loop");
- 
+     
+     ophonekitd_dbus_start();
+     
+     dbus_connect_to_bus(&fwHandler);
+     g_debug("Connected to the buses");
+     
      /* Start glib main loop and run list_resources() */
      g_timeout_add(0, list_resources, NULL);
      g_main_loop_run(mainloop);
@@@ -84,38 -85,25 +95,38 @@@
  }
  
  
 -void ophonekitd_call_add(int **calls, int *size, int id) {
 +void ophonekitd_call_add(call_t **calls, int *size, int id, int unique_id) {
 +	g_debug("ophonekitd_call_add(%d, %u)", id, unique_id);
      (*size)++;
      if(*size == 1)
 -        *calls = malloc(sizeof(int));
 +        *calls = malloc(sizeof(call_t));
      else
 -        *calls = realloc(calls, sizeof(int)*(*size));
 -    *calls[(*size)-1] = id;
 +        *calls = realloc(calls, sizeof(call_t)*(*size));
 +    (*calls)[(*size)-1].id = id;
 +    (*calls)[(*size)-1].unique_id = unique_id;
  }
  
 -int ophonekitd_call_check(int *calls, int *size, int id) {
 +int ophonekitd_call_check(call_t *calls, int *size, int id) {
      int i;
 +	g_debug("ophonekitd_call_check(%d)", id);
      for(i = 0; i < (*size) ; i++) {
 -        if(calls[i] == id)
 +        if(calls[i].id == id)
              return i;
      }
      return -1;
  }
  
 -void ophonekitd_call_remove(int *calls, int *size, int id) {
 +int ophonekitd_call_get_unique_id(call_t *calls, int *size, int id) {
 +	g_debug("ophonekitd_call_get_number(%d)", id);
 +    int place = ophonekitd_call_check(calls, size, id);
 +    if(place >= 0) {
 +    	return calls[place].unique_id;
 +    }
 +    return -1;
 +}
 +
 +void ophonekitd_call_remove(call_t *calls, int *size, int id) {
 +	g_debug("ophonekitd_call_remove(%d)", id);
      if(*size == 1)  {
          free(calls);
          (*size)--;
@@@ -125,11 -113,10 +136,11 @@@
          if(place >= 0) {
              int i = place;
              for(i = place; i + 1 < (*size); i++) {
 -                calls[i] = calls[i+1];
 +                calls[i].id = calls[i+1].id;
 +                calls[i].unique_id = calls[i+1].unique_id;
              }
 -            (*size)--;                
 -            calls = realloc(calls, sizeof(int)*(*size));
 +            (*size)--;
 +            calls = realloc(calls, sizeof(call_t)*(*size));
          }
      }
  }
@@@ -174,34 -161,24 +185,34 @@@ void ophonekitd_call_status_handler(con
          case CALL_STATUS_INCOMING:
              g_debug("incoming call");
              if(ophonekitd_call_check(incoming_calls, &incoming_calls_size, call_id) == -1) {
 -                ophonekitd_call_add(&incoming_calls, &incoming_calls_size, call_id);
 +                int unique_id = phonelog_add_new_call(number);
 +                ophonekitd_call_add(&incoming_calls, &incoming_calls_size, call_id, unique_id);
 +                phonelog_log_call_event(unique_id, status);
                  phonegui_incoming_call_show(call_id, status, number);
              }
              break;
          case CALL_STATUS_OUTGOING:
              g_debug("outgoing call");
              if(ophonekitd_call_check(outgoing_calls, &outgoing_calls_size, call_id) == -1) {
 -                ophonekitd_call_add(&outgoing_calls, &outgoing_calls_size, call_id);
 +                int unique_id = phonelog_add_new_call(number);
 +                ophonekitd_call_add(&outgoing_calls, &outgoing_calls_size, call_id, unique_id);
 +                phonelog_log_call_event(unique_id, status);
                  phonegui_outgoing_call_show(call_id, status, number);
              }
              break;
          case CALL_STATUS_RELEASE:
              g_debug("release call");
              if(ophonekitd_call_check(incoming_calls, &incoming_calls_size, call_id) != -1) {
 +                int unique_id =
 +                    ophonekitd_call_get_unique_id(incoming_calls, &incoming_calls_size, call_id);
 +                phonelog_log_call_event(unique_id, status);
                  ophonekitd_call_remove(incoming_calls, &incoming_calls_size, call_id);
                  phonegui_incoming_call_hide(call_id);
              }
              if(ophonekitd_call_check(outgoing_calls, &outgoing_calls_size, call_id) != -1) {
 +                int unique_id =
 +                    ophonekitd_call_get_unique_id(outgoing_calls, &outgoing_calls_size, call_id);
 +                phonelog_log_call_event(unique_id, status);
                  ophonekitd_call_remove(outgoing_calls, &outgoing_calls_size, call_id);
                  phonegui_outgoing_call_hide(call_id);
              }
@@@ -211,16 -188,6 +222,16 @@@
              break;
          case CALL_STATUS_ACTIVE:
              g_debug("active call");
 +            if(ophonekitd_call_check(incoming_calls, &incoming_calls_size, call_id) != -1) {
 +                int unique_id =
 +                    ophonekitd_call_get_unique_id(incoming_calls, &incoming_calls_size, call_id);
 +                phonelog_log_call_event(unique_id, status);
 +            }
 +            if(ophonekitd_call_check(outgoing_calls, &outgoing_calls_size, call_id) != -1) {
 +                int unique_id =
 +                    ophonekitd_call_get_unique_id(outgoing_calls, &outgoing_calls_size, call_id);
 +                phonelog_log_call_event(unique_id, status);
 +            }
              break;
          default:
              g_error("Unknown CallStatus");
@@@ -309,7 -276,7 +320,7 @@@ void request_resource_callback(GError *
      } else if(IS_DBUS_ERROR(error, DBUS_ERROR_SERVICE_NOT_AVAILABLE) || IS_DBUS_ERROR(error, DBUS_ERROR_NO_REPLY)) {
          g_debug("dbus not available, try again in 5s");
          g_timeout_add(5000, list_resources, NULL);
 -    } else {   
 +    } else {
          /* FIXME: Remove this when frameworkd code is ready */
          g_debug("request resource error, try again in 5s");
          g_error("error: %s %s %d", error->message, g_quark_to_string(error->domain), error->code);
@@@ -335,7 -302,7 +346,7 @@@ void power_up_antenna_callback(GError *
              g_error("SIM card not present.");
          } else if(IS_DBUS_ERROR(error, DBUS_ERROR_SERVICE_NOT_AVAILABLE) || IS_DBUS_ERROR(error, DBUS_ERROR_NO_REPLY)) {
              g_debug("dbus not available, try again in 5s");
 -            g_timeout_add(5000, power_up_antenna, NULL);        
 +            g_timeout_add(5000, power_up_antenna, NULL);
          } else {
              g_error("Unknown error: %s %s %d", error->message, g_quark_to_string(error->domain), error->code);
          }
@@@ -401,11 -368,6 +412,11 @@@ void get_messagebook_info_callback(GErr
  int exit_callback(void *data, int type, void *event) {
      /* called on ctrl-c, kill $pid, SIGINT, SIGTERM and SIGQIT */
      g_debug("exit_callback()");
 +
 +    /* Close phonelog database */
 +    phonelog_close_database();
 +    g_debug("Phonelog database closed");
 +
      return 0;
  }
  

-- 
libframeworkd-phonegui



More information about the pkg-fso-commits mailing list