Code changes to support Template object creation and usage
authorSuresh Kumar N <suresh.n@samsung.com>
Fri, 30 Nov 2012 12:37:27 +0000 (18:07 +0530)
committerwootak.jung <wootak.jung@samsung.com>
Sun, 24 Mar 2013 09:03:04 +0000 (18:03 +0900)
30 files changed:
include/at.h
include/co_call.h
include/co_context.h
include/co_gps.h
include/co_modem.h
include/co_network.h
include/co_phonebook.h
include/co_ps.h
include/co_sap.h
include/co_sat.h
include/co_sim.h
include/co_sms.h
include/co_ss.h
include/core_object.h
include/server.h
src/at.c
src/co_call.c
src/co_context.c
src/co_gps.c
src/co_modem.c
src/co_network.c
src/co_phonebook.c
src/co_ps.c
src/co_sap.c
src/co_sat.c
src/co_sim.c
src/co_sms.c
src/co_ss.c
src/core_object.c
src/server.c

index e6db17f..383ffdb 100755 (executable)
@@ -143,7 +143,15 @@ void             tcore_at_tok_free(GSList *tokens);
 char*            tcore_at_tok_extract(const char *src);
 char*            tcore_at_tok_nth(GSList *tokens, unsigned int token_index);
 
-
+TReturn tcore_prepare_and_send_at_request(CoreObject *co,
+                                                                                               const char *at_cmd,
+                                                                                               const char *at_cmd_prefix,
+                                                                                               enum tcore_at_command_type at_cmd_type,
+                                                                                               UserRequest *ur,
+                                                                                               TcorePendingResponseCallback resp_cb,
+                                                                                               void *resp_cb_data,
+                                                                                               TcorePendingSendCallback send_cb,
+                                                                                               void *send_cb_data);
 __END_DECLS
 
 #endif
index f0459f6..a2cb256 100644 (file)
@@ -153,6 +153,11 @@ struct tcore_call_control_operations {
 CoreObject*                            tcore_call_new(TcorePlugin *p, const char *name, struct tcore_call_operations *ops, TcoreHal *hal);
 void                                   tcore_call_free( CoreObject *o);
 
+CoreObject *tcore_call_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_call_override_ops(CoreObject *o,
+                                                                               struct tcore_call_operations *call_ops,
+                                                                               struct tcore_call_control_operations *control_ops,
+                                                                               struct tcore_call_information_operations *info_ops);
 
 // Call Object API
 CallObject*                            tcore_call_object_new( CoreObject *o, int id );
index 64aeca2..1f0d029 100644 (file)
@@ -75,6 +75,8 @@ enum co_context_auth {
 CoreObject*              tcore_context_new(TcorePlugin *p, const char *name, TcoreHal *hal);
 void                     tcore_context_free(CoreObject *o);
 
+CoreObject *tcore_context_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+
 TReturn                  tcore_context_set_state(CoreObject *o, enum co_context_state state);
 enum co_context_state    tcore_context_get_state(CoreObject *o);
 TReturn                  tcore_context_set_id(CoreObject *o, unsigned int id);
index 9cc5b10..ddb3107 100644 (file)
@@ -34,6 +34,9 @@ struct tcore_gps_operations {
 CoreObject*  tcore_gps_new(TcorePlugin *p, const char *name, struct tcore_gps_operations *ops, TcoreHal *hal);
 void         tcore_gps_free(CoreObject *o);
 
+CoreObject *tcore_gps_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_gps_override_ops(CoreObject *o, struct tcore_gps_operations *gps_ops);
+
 __END_DECLS
 
 #endif
index c9ce420..d42d3f8 100644 (file)
@@ -38,10 +38,12 @@ struct tcore_modem_operations {
        TReturn (*get_flight_mode)(CoreObject *o, UserRequest *ur);
 };
 
-
 CoreObject*      tcore_modem_new(TcorePlugin *p, const char *name, struct tcore_modem_operations *ops, TcoreHal *hal);
 void             tcore_modem_free(CoreObject *o);
 
+CoreObject *tcore_modem_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_modem_override_ops(CoreObject *o, struct tcore_modem_operations *modem_ops);
+
 TReturn          tcore_modem_set_flight_mode_state(CoreObject *o, gboolean flag);
 gboolean         tcore_modem_get_flight_mode_state(CoreObject *o);
 TReturn          tcore_modem_set_powered(CoreObject *o, gboolean pwr);
index d866f04..eadbead 100644 (file)
@@ -73,11 +73,13 @@ struct tcore_network_operations {
        TReturn (*get_neighboring_cell_info)(CoreObject *o, UserRequest *ur);
 };
 
-
 CoreObject* tcore_network_new(TcorePlugin *plugin, const char *name,
                 struct tcore_network_operations *ops, TcoreHal *hal);
 void        tcore_network_free(CoreObject *co);
 
+CoreObject *tcore_network_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_network_override_ops(CoreObject *o, struct tcore_network_operations *network_ops);
+
 TReturn     tcore_network_set_plmn(CoreObject *co, const char *plmn);
 char*       tcore_network_get_plmn(CoreObject *co);
 
index 8cefb1b..b7e2662 100644 (file)
@@ -37,6 +37,9 @@ struct tcore_phonebook_operations {
 CoreObject* tcore_phonebook_new(TcorePlugin *p, const char *name, struct tcore_phonebook_operations *ops, TcoreHal *hal);
 void        tcore_phonebook_free(CoreObject *n);
 
+CoreObject *tcore_phonebook_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_phonebook_override_ops(CoreObject *o, struct tcore_phonebook_operations *phonebook_ops);
+
 gboolean    tcore_phonebook_get_status(CoreObject *o);
 gboolean    tcore_phonebook_set_status(CoreObject *o, gboolean b_init);
 
index 8cf2fe5..4495441 100644 (file)
@@ -38,6 +38,9 @@ struct tcore_ps_operations {
 CoreObject*  tcore_ps_new(TcorePlugin *p, const char *name, struct tcore_ps_operations *ops, TcoreHal *hal);
 void         tcore_ps_free(CoreObject *o);
 
+CoreObject *tcore_ps_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_ps_override_ops(CoreObject *o, struct tcore_ps_operations *ps_ops);
+
 TReturn      tcore_ps_add_context(CoreObject *o, CoreObject *ctx_o);
 TReturn      tcore_ps_remove_context(CoreObject *o, CoreObject *ctx_o);
 CoreObject*  tcore_ps_ref_context_by_role(CoreObject *o, enum co_context_role role);
index a8a3fab..5647374 100644 (file)
@@ -39,6 +39,9 @@ struct tcore_sap_operations {
 CoreObject* tcore_sap_new(TcorePlugin *p, const char *name, struct tcore_sap_operations *ops, TcoreHal *hal);
 void        tcore_sap_free(CoreObject *o);
 
+CoreObject *tcore_sap_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_sap_override_ops(CoreObject *o, struct tcore_sap_operations *sap_ops);
+
 __END_DECLS
 
 #endif
index ad9f35a..856a1f3 100644 (file)
@@ -88,4 +88,7 @@ int tcore_sat_encode_terminal_response(const struct treq_sat_terminal_rsp_data *
 CoreObject* tcore_sat_new(TcorePlugin *p, const char *name, struct tcore_sat_operations *ops, TcoreHal *hal);
 void        tcore_sat_free(CoreObject *n);
 
+CoreObject *tcore_sat_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_sat_override_ops(CoreObject *o, struct tcore_sat_operations *sat_ops);
+
 #endif
index 611f8de..eebb1cd 100644 (file)
@@ -43,6 +43,9 @@ struct tcore_sim_operations {
 CoreObject*          tcore_sim_new(TcorePlugin *p, const char *name, struct tcore_sim_operations *ops, TcoreHal *hal);
 void                 tcore_sim_free(CoreObject *n);
 
+CoreObject *tcore_sim_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_sim_override_ops(CoreObject *o, struct tcore_sim_operations *sim_ops);
+
 enum tel_sim_type    tcore_sim_get_type(CoreObject *o);
 gboolean             tcore_sim_set_type(CoreObject *o, enum tel_sim_type type);
 
index 576ef76..d216832 100644 (file)
@@ -73,6 +73,9 @@ gboolean    tcore_sms_set_ready_status(CoreObject *o, int status);
 CoreObject* tcore_sms_new(TcorePlugin *p, const char *name, struct tcore_sms_operations *ops, TcoreHal *hal);
 void        tcore_sms_free(CoreObject * n);
 
+CoreObject *tcore_sms_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_sms_override_ops(CoreObject *o, struct tcore_sms_operations *sms_ops);
+
 __END_DECLS
 
 #endif
index ca809ac..165b971 100644 (file)
@@ -179,6 +179,9 @@ struct tcore_ss_operations {
 CoreObject* tcore_ss_new(TcorePlugin *p, const char *name, struct tcore_ss_operations *ops, TcoreHal *hal);
 void        tcore_ss_free(CoreObject *o);
 
+CoreObject *tcore_ss_clone(TcorePlugin *p, const char *name, TcoreHal *hal);
+void tcore_ss_override_ops(CoreObject *o, struct tcore_ss_operations *ss_ops);
+
 struct ussd_session*   tcore_ss_ussd_create_session( CoreObject *o, enum tcore_ss_ussd_type type, void *data, int data_len );
 void                                   tcore_ss_ussd_destroy_session( struct ussd_session *ussd_s );
 struct ussd_session*   tcore_ss_ussd_get_session( CoreObject *o );
index 0f07e55..5fc0080 100644 (file)
@@ -58,6 +58,7 @@ TReturn          tcore_object_set_free_hook(CoreObject *co, CoreObjectFreeHook f
 TReturn          tcore_object_set_clone_hook(CoreObject *co, CoreObjectCloneHook clone_hook);
 
 CoreObject*      tcore_object_clone(CoreObject *src, TcorePlugin *new_parent, const char *new_name);
+CoreObject *tcore_object_clone_template_object(TcorePlugin *p, const char *co_name, unsigned int co_type);
 
 TReturn          tcore_object_set_name(CoreObject *co, const char *name);
 const char*      tcore_object_ref_name(CoreObject *co);
index 1f9a305..1292824 100644 (file)
@@ -51,6 +51,10 @@ TReturn       tcore_server_add_hal(Server *s, TcoreHal *hal);
 GSList*       tcore_server_ref_hals(Server *s);
 TcoreHal*     tcore_server_find_hal(Server *s, const char *name);
 
+TReturn tcore_server_add_template_object(Server *s, CoreObject *template_co);
+GSList *tcore_server_ref_template_object(Server *s);
+CoreObject *tcore_server_find_template_object(Server *s, unsigned int type);
+
 TReturn       tcore_server_link_udev(Server *s, TcoreUdev *udev);
 TcoreUdev*    tcore_server_ref_udev(Server *s);
 
index 0c4037a..d134e06 100755 (executable)
--- a/src/at.c
+++ b/src/at.c
@@ -30,6 +30,7 @@
 #include "queue.h"
 #include "user_request.h"
 #include "at.h"
+#include "core_object.h"
 
 #define NUM_ELEMS(x) (sizeof(x)/sizeof(x[0]))
 #define MODE_HEX       0
@@ -972,3 +973,49 @@ gboolean tcore_at_add_hook(TcoreHal *hal, void *hook_func)
        dbg("AT is NULL !!!");
        return FALSE;
 }
+
+TReturn tcore_prepare_and_send_at_request(CoreObject *co,
+                                                                                               const char *at_cmd,
+                                                                                               const char *at_cmd_prefix,
+                                                                                               enum tcore_at_command_type at_cmd_type,
+                                                                                               UserRequest *ur,
+                                                                                               TcorePendingResponseCallback resp_cb,
+                                                                                               void *resp_cb_data,
+                                                                                               TcorePendingSendCallback send_cb,
+                                                                                               void *send_cb_data)
+{
+       TcorePending *pending = NULL;
+       TcoreATRequest *req = NULL;
+       TcoreHal *hal = NULL;
+       TReturn ret = TCORE_RETURN_FAILURE;
+
+       hal = tcore_object_get_hal(co);
+       if (!hal) {
+               dbg("HAL is NULL");
+               return ret;
+       }
+
+       /* Create Pending Request */
+       pending = tcore_pending_new(co, 0);
+       if (!pending) {
+               dbg("Pending is NULL");
+               return ret;
+       }
+
+       /* Create AT-Command Request */
+       req = tcore_at_request_new(at_cmd, at_cmd_prefix, at_cmd_type);
+       if (!req) {
+               dbg("Request is NULL");
+               tcore_pending_free(pending);
+               return ret;
+       }
+       dbg("AT Command: %s, Prefix(if any):%s, AT-Command length: %d", req->cmd, req->prefix, strlen(req->cmd));
+
+       tcore_pending_set_request_data(pending, 0, req);
+       tcore_pending_set_response_callback(pending, resp_cb, resp_cb_data);
+       tcore_pending_set_send_callback(pending, send_cb, send_cb_data);
+       tcore_pending_link_user_request(pending, ur);
+
+       ret = tcore_hal_send_request(hal, pending);
+       return ret;
+}
index c22943e..29c061d 100644 (file)
@@ -97,6 +97,201 @@ static void _clone_hook(CoreObject *src, CoreObject *dest)
        tcore_object_link_object(dest, dest_po);
 }
 
+static void _clone_call_operations(struct private_object_data *po, struct tcore_call_operations *call_ops)
+{
+       if(call_ops->dial) {
+               po->ops->dial = call_ops->dial;
+       }
+       if(call_ops->answer) {
+               po->ops->answer = call_ops->answer;
+       }
+       if(call_ops->end) {
+               po->ops->end = call_ops->end;
+       }
+       if(call_ops->hold) {
+               po->ops->hold = call_ops->hold;
+       }
+       if(call_ops->active) {
+               po->ops->active = call_ops->active;
+       }
+       if(call_ops->swap) {
+               po->ops->swap = call_ops->swap;
+       }
+       if(call_ops->join) {
+               po->ops->join = call_ops->join;
+       }
+       if(call_ops->split) {
+               po->ops->split = call_ops->split;
+       }
+       if(call_ops->deflect) {
+               po->ops->deflect = call_ops->deflect;
+       }
+       if(call_ops->transfer) {
+               po->ops->transfer = call_ops->transfer;
+       }
+       if(call_ops->send_dtmf) {
+               po->ops->send_dtmf = call_ops->send_dtmf;
+       }
+       if(call_ops->set_sound_path) {
+               po->ops->set_sound_path = call_ops->set_sound_path;
+       }
+       if(call_ops->set_sound_volume_level) {
+               po->ops->set_sound_volume_level = call_ops->set_sound_volume_level;
+       }
+       if(call_ops->get_sound_volume_level) {
+               po->ops->get_sound_volume_level = call_ops->get_sound_volume_level;
+       }
+       if(call_ops->mute) {
+               po->ops->mute = call_ops->mute;
+       }
+       if(call_ops->unmute) {
+               po->ops->unmute = call_ops->unmute;
+       }
+       if(call_ops->get_mute_status) {
+               po->ops->get_mute_status = call_ops->get_mute_status;
+       }
+       if(call_ops->set_sound_recording) {
+               po->ops->set_sound_recording = call_ops->set_sound_recording;
+       }
+       if(call_ops->set_sound_equalization) {
+               po->ops->set_sound_equalization = call_ops->set_sound_equalization;
+       }
+       if(call_ops->set_sound_noise_reduction) {
+               po->ops->set_sound_noise_reduction = call_ops->set_sound_noise_reduction;
+       }
+       if(call_ops->set_active_line) {
+               po->ops->set_active_line = call_ops->set_active_line;
+       }
+       if(call_ops->get_active_line) {
+               po->ops->get_active_line = call_ops->get_active_line;
+       }
+       if(call_ops->activate_ccbs) {
+               po->ops->activate_ccbs = call_ops->activate_ccbs;
+       }
+
+       return;
+}
+
+static void _clone_call_control_operations(struct private_object_data *po, struct tcore_call_control_operations *control_ops)
+{
+       if(control_ops->answer_hold_and_accept) {
+               po->cops->answer_hold_and_accept = control_ops->answer_hold_and_accept;
+       }
+       if(control_ops->answer_replace) {
+               po->cops->answer_replace = control_ops->answer_replace;
+       }
+       if(control_ops->answer_reject) {
+               po->cops->answer_reject = control_ops->answer_reject;
+       }
+       if(control_ops->end_specific) {
+               po->cops->end_specific = control_ops->end_specific;
+       }
+       if(control_ops->end_all_active) {
+               po->cops->end_all_active = control_ops->end_all_active;
+       }
+       if(control_ops->end_all_held) {
+               po->cops->end_all_held = control_ops->end_all_held;
+       }
+       if(control_ops->active) {
+               po->cops->active = control_ops->active;
+       }
+       if(control_ops->hold) {
+               po->cops->hold = control_ops->hold;
+       }
+       if(control_ops->swap) {
+               po->cops->swap = control_ops->swap;
+       }
+       if(control_ops->join) {
+               po->cops->join = control_ops->join;
+       }
+       if(control_ops->split) {
+               po->cops->split = control_ops->split;
+       }
+       if(control_ops->transfer) {
+               po->cops->transfer = control_ops->transfer;
+       }
+       if(control_ops->deflect) {
+               po->cops->deflect = control_ops->deflect;
+       }
+
+       return;
+}
+
+static void _clone_call_info_operations(struct private_object_data *po, struct tcore_call_information_operations *info_ops)
+{
+       if(info_ops->mo_call_col) {
+               po->iops->mo_call_col = info_ops->mo_call_col;
+       }
+       if(info_ops->mo_call_waiting) {
+               po->iops->mo_call_waiting = info_ops->mo_call_waiting;
+       }
+       if(info_ops->mo_call_cug) {
+               po->iops->mo_call_cug = info_ops->mo_call_cug;
+       }
+       if(info_ops->mo_call_forwarded) {
+               po->iops->mo_call_forwarded = info_ops->mo_call_forwarded;
+       }
+       if(info_ops->mo_call_barred_incoming) {
+               po->iops->mo_call_barred_incoming = info_ops->mo_call_barred_incoming;
+       }
+       if(info_ops->mo_call_barred_outgoing) {
+               po->iops->mo_call_barred_outgoing = info_ops->mo_call_barred_outgoing;
+       }
+       if(info_ops->mo_call_deflected) {
+               po->iops->mo_call_deflected = info_ops->mo_call_deflected;
+       }
+       if(info_ops->mo_call_clir_suppression_reject) {
+               po->iops->mo_call_clir_suppression_reject = info_ops->mo_call_clir_suppression_reject;
+       }
+       if(info_ops->mo_call_cfu) {
+               po->iops->mo_call_cfu = info_ops->mo_call_cfu;
+       }
+       if(info_ops->mo_call_cfc) {
+               po->iops->mo_call_cfc = info_ops->mo_call_cfc;
+       }
+       if(info_ops->mt_call_cli) {
+               po->iops->mt_call_cli = info_ops->mt_call_cli;
+       }
+       if(info_ops->mt_call_cna) {
+               po->iops->mt_call_cna = info_ops->mt_call_cna;
+       }
+       if(info_ops->mt_call_forwarded_call) {
+               po->iops->mt_call_forwarded_call = info_ops->mt_call_forwarded_call;
+       }
+       if(info_ops->mt_call_cug_call) {
+               po->iops->mt_call_cug_call = info_ops->mt_call_cug_call;
+       }
+       if(info_ops->mt_call_deflected_call) {
+               po->iops->mt_call_deflected_call = info_ops->mt_call_deflected_call;
+       }
+       if(info_ops->mt_call_transfered) {
+               po->iops->mt_call_transfered = info_ops->mt_call_transfered;
+       }
+       if(info_ops->call_held) {
+               po->iops->call_held = info_ops->call_held;
+       }
+       if(info_ops->call_active) {
+               po->iops->call_active = info_ops->call_active;
+       }
+       if(info_ops->call_joined) {
+               po->iops->call_joined = info_ops->call_joined;
+       }
+       if(info_ops->call_released_on_hold) {
+               po->iops->call_released_on_hold = info_ops->call_released_on_hold;
+       }
+       if(info_ops->call_transfer_alert) {
+               po->iops->call_transfer_alert = info_ops->call_transfer_alert;
+       }
+       if(info_ops->call_transfered) {
+               po->iops->call_transfered = info_ops->call_transfered;
+       }
+       if(info_ops->call_cf_check_message) {
+               po->iops->call_cf_check_message = info_ops->call_cf_check_message;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -1099,6 +1294,35 @@ void tcore_call_information_set_operations(CoreObject *o, struct tcore_call_info
        po->iops = ops;
 }
 
+void tcore_call_override_ops(CoreObject *o,
+                                                                               struct tcore_call_operations *call_ops,
+                                                                               struct tcore_call_control_operations *control_ops,
+                                                                               struct tcore_call_information_operations *info_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_CALL);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(call_ops) {
+               _clone_call_operations(po, call_ops);
+       }
+
+       if(control_ops) {
+               _clone_call_control_operations(po, control_ops);
+       }
+
+       if(info_ops) {
+               _clone_call_info_operations(po, info_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_call_new(TcorePlugin *p, const char *name, struct tcore_call_operations *ops, TcoreHal *hal)
 {
        CoreObject *o = NULL;
@@ -1128,6 +1352,22 @@ CoreObject *tcore_call_new(TcorePlugin *p, const char *name, struct tcore_call_o
        return o;
 }
 
+CoreObject *tcore_call_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_CALL);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_call_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index c04bb7b..101339f 100644 (file)
@@ -102,6 +102,22 @@ CoreObject *tcore_context_new(TcorePlugin *p, const char *name, TcoreHal *hal)
        return o;
 }
 
+CoreObject *tcore_context_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_PS_CONTEXT);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_context_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index 144e59f..15852fa 100644 (file)
@@ -53,6 +53,15 @@ static void _clone_hook(CoreObject *src, CoreObject *dest)
        tcore_object_link_object(dest, dest_po);
 }
 
+static void _clone_gps_operations(struct private_object_data *po, struct tcore_gps_operations *gps_ops)
+{
+       if(gps_ops->confirm_measure_pos) {
+               po->ops->confirm_measure_pos = gps_ops->confirm_measure_pos;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -90,6 +99,24 @@ static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
        return TCORE_RETURN_SUCCESS;
 }
 
+void tcore_gps_override_ops(CoreObject *o, struct tcore_gps_operations *gps_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_GPS);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(gps_ops) {
+               _clone_gps_operations(po, gps_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_gps_new(TcorePlugin *p, const char *name,
                struct tcore_gps_operations *ops, TcoreHal *hal)
 {
@@ -119,6 +146,22 @@ CoreObject *tcore_gps_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_gps_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_GPS);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_gps_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index cdd47d0..8070b62 100755 (executable)
@@ -68,6 +68,39 @@ static void _clone_hook(CoreObject *src, CoreObject *dest)
        tcore_object_link_object(dest, dest_po);
 }
 
+static void _clone_modem_operations(struct private_object_data *po, struct tcore_modem_operations *modem_ops)
+{
+       if(modem_ops->power_on) {
+               po->ops->power_on = modem_ops->power_on;
+       }
+       if(modem_ops->power_off) {
+               po->ops->power_off = modem_ops->power_off;
+       }
+       if(modem_ops->power_reset) {
+               po->ops->power_reset = modem_ops->power_reset;
+       }
+       if(modem_ops->set_flight_mode) {
+               po->ops->set_flight_mode = modem_ops->set_flight_mode;
+       }
+       if(modem_ops->get_imei) {
+               po->ops->get_imei = modem_ops->get_imei;
+       }
+       if(modem_ops->get_version) {
+               po->ops->get_version = modem_ops->get_version;
+       }
+       if(modem_ops->get_sn) {
+               po->ops->get_sn = modem_ops->get_sn;
+       }
+       if(modem_ops->dun_pin_ctrl) {
+               po->ops->dun_pin_ctrl = modem_ops->dun_pin_ctrl;
+       }
+       if(modem_ops->get_flight_mode) {
+               po->ops->get_flight_mode = modem_ops->get_flight_mode;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -151,6 +184,24 @@ static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
        return TCORE_RETURN_SUCCESS;
 }
 
+void tcore_modem_override_ops(CoreObject *o, struct tcore_modem_operations *modem_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_MODEM);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(modem_ops) {
+               _clone_modem_operations(po, modem_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_modem_new(TcorePlugin *p, const char *name,
                struct tcore_modem_operations *ops, TcoreHal *hal)
 {
@@ -179,6 +230,22 @@ CoreObject *tcore_modem_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_modem_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_MODEM);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_modem_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index 3b5f097..b6db77d 100644 (file)
@@ -51,6 +51,63 @@ struct private_object_data {
        GSList *network_operator_info_table[1000];
 };
 
+static void _clone_network_operations(struct private_object_data *po, struct tcore_network_operations *network_ops)
+{
+       if(network_ops->search) {
+               po->ops->search = network_ops->search;
+       }
+       if(network_ops->set_plmn_selection_mode) {
+               po->ops->set_plmn_selection_mode = network_ops->set_plmn_selection_mode;
+       }
+       if(network_ops->get_plmn_selection_mode) {
+               po->ops->get_plmn_selection_mode = network_ops->get_plmn_selection_mode;
+       }
+       if(network_ops->set_service_domain) {
+               po->ops->set_service_domain = network_ops->set_service_domain;
+       }
+       if(network_ops->get_service_domain) {
+               po->ops->get_service_domain = network_ops->get_service_domain;
+       }
+       if(network_ops->set_band) {
+               po->ops->set_band = network_ops->set_band;
+       }
+       if(network_ops->get_band) {
+               po->ops->get_band = network_ops->get_band;
+       }
+       if(network_ops->set_preferred_plmn) {
+               po->ops->set_preferred_plmn = network_ops->set_preferred_plmn;
+       }
+       if(network_ops->get_preferred_plmn) {
+               po->ops->get_preferred_plmn = network_ops->get_preferred_plmn;
+       }
+       if(network_ops->set_order) {
+               po->ops->set_order = network_ops->set_order;
+       }
+       if(network_ops->get_order) {
+               po->ops->get_order = network_ops->get_order;
+       }
+       if(network_ops->set_power_on_attach) {
+               po->ops->set_power_on_attach = network_ops->set_power_on_attach;
+       }
+       if(network_ops->get_power_on_attach) {
+               po->ops->get_power_on_attach = network_ops->get_power_on_attach;
+       }
+       if(network_ops->set_cancel_manual_search) {
+               po->ops->set_cancel_manual_search = network_ops->set_cancel_manual_search;
+       }
+       if(network_ops->get_serving_network) {
+               po->ops->get_serving_network = network_ops->get_serving_network;
+       }
+       if(network_ops->set_mode) {
+               po->ops->set_mode = network_ops->set_mode;
+       }
+       if(network_ops->get_mode) {
+               po->ops->get_mode = network_ops->get_mode;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *co, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -237,6 +294,24 @@ static void _clone_hook(CoreObject *src, CoreObject *dest)
        tcore_object_link_object(dest, dest_po);
 }
 
+void tcore_network_override_ops(CoreObject *o, struct tcore_network_operations *network_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_NETWORK);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(network_ops) {
+               _clone_network_operations(po, network_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_network_new(TcorePlugin *plugin, const char *name,
                struct tcore_network_operations *ops, TcoreHal *hal)
 {
@@ -267,6 +342,22 @@ CoreObject *tcore_network_new(TcorePlugin *plugin, const char *name,
        return o;
 }
 
+CoreObject *tcore_network_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_NETWORK);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_network_free(CoreObject *co)
 {
        struct private_object_data *po = NULL;
index c77f2eb..b44b546 100644 (file)
@@ -38,6 +38,30 @@ struct private_object_data {
        enum tel_phonebook_type selected;
 };
 
+static void _clone_phonebook_operations(struct private_object_data *po, struct tcore_phonebook_operations *phonebook_ops)
+{
+       if(phonebook_ops->get_count) {
+               po->ops->get_count = phonebook_ops->get_count;
+       }
+       if(phonebook_ops->get_info) {
+               po->ops->get_info = phonebook_ops->get_info;
+       }
+       if(phonebook_ops->get_usim_info) {
+               po->ops->get_usim_info = phonebook_ops->get_usim_info;
+       }
+       if(phonebook_ops->read_record) {
+               po->ops->read_record = phonebook_ops->read_record;
+       }
+       if(phonebook_ops->update_record) {
+               po->ops->update_record = phonebook_ops->update_record;
+       }
+       if(phonebook_ops->delete_record) {
+               po->ops->delete_record = phonebook_ops->delete_record;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -187,6 +211,24 @@ gboolean tcore_phonebook_set_selected_type(CoreObject *o, enum tel_phonebook_typ
        return TRUE;
 }
 
+void tcore_phonebook_override_ops(CoreObject *o, struct tcore_phonebook_operations *phonebook_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_PHONEBOOK);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(phonebook_ops) {
+               _clone_phonebook_operations(po, phonebook_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_phonebook_new(TcorePlugin *p, const char *name,
                struct tcore_phonebook_operations *ops, TcoreHal *hal)
 {
@@ -218,6 +260,22 @@ CoreObject *tcore_phonebook_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_phonebook_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_PHONEBOOK);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_phonebook_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index 21f0118..b8efb12 100644 (file)
@@ -46,6 +46,18 @@ struct private_object_data {
        GSList *context_list;
 };
 
+static void _clone_ps_operations(struct private_object_data *po, struct tcore_ps_operations *ps_ops)
+{
+       if(ps_ops->activate_context) {
+               po->ops->activate_context = ps_ops->activate_context;
+       }
+       if(ps_ops->deactivate_context) {
+               po->ops->deactivate_context = ps_ops->deactivate_context;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -195,6 +207,24 @@ static gboolean _ps_is_duplicated_apn(CoreObject *o, CoreObject *ps_context)
        return FALSE;
 }
 
+void tcore_ps_override_ops(CoreObject *o, struct tcore_ps_operations *ps_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_PS);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(ps_ops) {
+               _clone_ps_operations(po, ps_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_ps_new(TcorePlugin *p, const char *name,
                struct tcore_ps_operations *ops, TcoreHal *hal)
 {
@@ -225,6 +255,22 @@ CoreObject *tcore_ps_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_ps_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_PS);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_ps_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index def550e..57a662c 100644 (file)
@@ -34,6 +34,36 @@ struct private_object_data {
        struct tcore_sap_operations *ops;
 };
 
+static void _clone_sap_operations(struct private_object_data *po, struct tcore_sap_operations *sap_ops)
+{
+       if(sap_ops->connect) {
+               po->ops->connect = sap_ops->connect;
+       }
+       if(sap_ops->disconnect) {
+               po->ops->disconnect = sap_ops->disconnect;
+       }
+       if(sap_ops->req_status) {
+               po->ops->req_status = sap_ops->req_status;
+       }
+       if(sap_ops->set_transport_protocol) {
+               po->ops->set_transport_protocol = sap_ops->set_transport_protocol;
+       }
+       if(sap_ops->set_power) {
+               po->ops->set_power = sap_ops->set_power;
+       }
+       if(sap_ops->get_atr) {
+               po->ops->get_atr = sap_ops->get_atr;
+       }
+       if(sap_ops->transfer_apdu) {
+               po->ops->transfer_apdu = sap_ops->transfer_apdu;
+       }
+       if(sap_ops->get_cardreader_status) {
+               po->ops->get_cardreader_status = sap_ops->get_cardreader_status;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -143,6 +173,24 @@ static void _free_hook(CoreObject *o)
        }
 }
 
+void tcore_sap_override_ops(CoreObject *o, struct tcore_sap_operations *sap_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SAP);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(sap_ops) {
+               _clone_sap_operations(po, sap_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_sap_new(TcorePlugin *p, const char *name,
                struct tcore_sap_operations *ops, TcoreHal *hal)
 {
@@ -173,6 +221,22 @@ CoreObject *tcore_sap_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_sap_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_SAP);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_sap_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index fbdcfa0..23029b9 100644 (file)
@@ -120,6 +120,18 @@ struct private_object_data {
 
 gboolean b_comprehensive = FALSE;
 
+static void _clone_sat_operations(struct private_object_data *po, struct tcore_sat_operations *sat_ops)
+{
+       if(sat_ops->envelope) {
+               po->ops->envelope = sat_ops->envelope;
+       }
+       if(sat_ops->terminal_response) {
+               po->ops->terminal_response = sat_ops->terminal_response;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -6854,6 +6866,24 @@ int tcore_sat_encode_terminal_response(const struct treq_sat_terminal_rsp_data *
        return tr_len;
 }
 
+void tcore_sat_override_ops(CoreObject *o, struct tcore_sat_operations *sat_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SAT);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(sat_ops) {
+               _clone_sat_operations(po, sat_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_sat_new(TcorePlugin *p, const char *name,
                struct tcore_sat_operations *ops, TcoreHal *hal)
 {
@@ -6884,6 +6914,22 @@ CoreObject *tcore_sat_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_sat_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_SAT);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_sat_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index 4c9d465..2a51dc1 100644 (file)
@@ -43,6 +43,47 @@ struct private_object_data {
        void *userdata; /**< free use data*/
 };
 
+static void _clone_sim_operations(struct private_object_data *po, struct tcore_sim_operations *sim_ops)
+{
+       if(sim_ops->verify_pins) {
+               po->ops->verify_pins = sim_ops->verify_pins;
+       }
+       if(sim_ops->verify_puks) {
+               po->ops->verify_puks = sim_ops->verify_puks;
+       }
+       if(sim_ops->change_pins) {
+               po->ops->change_pins = sim_ops->change_pins;
+       }
+       if(sim_ops->get_facility_status) {
+               po->ops->get_facility_status = sim_ops->get_facility_status;
+       }
+       if(sim_ops->enable_facility) {
+               po->ops->enable_facility = sim_ops->enable_facility;
+       }
+       if(sim_ops->disable_facility) {
+               po->ops->disable_facility = sim_ops->disable_facility;
+       }
+       if(sim_ops->get_lock_info) {
+               po->ops->get_lock_info = sim_ops->get_lock_info;
+       }
+       if(sim_ops->read_file) {
+               po->ops->read_file = sim_ops->read_file;
+       }
+       if(sim_ops->update_file) {
+               po->ops->update_file = sim_ops->update_file;
+       }
+       if(sim_ops->transmit_apdu) {
+               po->ops->transmit_apdu = sim_ops->transmit_apdu;
+       }
+       if(sim_ops->get_atr) {
+               po->ops->get_atr = sim_ops->get_atr;
+       }
+       if(sim_ops->req_authentication) {
+               po->ops->req_authentication = sim_ops->req_authentication;
+       }
+
+       return;
+}
 
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
@@ -2477,6 +2518,24 @@ static void tcore_sim_initialize_context(CoreObject *o)
        po->sim_status = SIM_STATUS_UNKNOWN;
 }
 
+void tcore_sim_override_ops(CoreObject *o, struct tcore_sim_operations *sim_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SIM);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(sim_ops) {
+               _clone_sim_operations(po, sim_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_sim_new(TcorePlugin *p, const char *name,
                struct tcore_sim_operations *ops, TcoreHal *hal)
 {
@@ -2509,6 +2568,22 @@ CoreObject *tcore_sim_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_sim_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_SIM);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_sim_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index 2fd96dc..f36b482 100644 (file)
@@ -129,6 +129,66 @@ int _tcore_util_sms_encode_smsParameters(const struct telephony_sms_Params *inco
 
 }
 
+static void _clone_sms_operations(struct private_object_data *po, struct tcore_sms_operations *sms_ops)
+{
+       if(sms_ops->send_umts_msg) {
+               po->ops->send_umts_msg = sms_ops->send_umts_msg;
+       }
+       if(sms_ops->read_msg) {
+               po->ops->read_msg = sms_ops->read_msg;
+       }
+       if(sms_ops->save_msg) {
+               po->ops->save_msg = sms_ops->save_msg;
+       }
+       if(sms_ops->delete_msg) {
+               po->ops->delete_msg = sms_ops->delete_msg;
+       }
+       if(sms_ops->get_storedMsgCnt) {
+               po->ops->get_storedMsgCnt = sms_ops->get_storedMsgCnt;
+       }
+       if(sms_ops->get_sca) {
+               po->ops->get_sca = sms_ops->get_sca;
+       }
+       if(sms_ops->set_sca) {
+               po->ops->set_sca = sms_ops->set_sca;
+       }
+       if(sms_ops->get_cb_config) {
+               po->ops->get_cb_config = sms_ops->get_cb_config;
+       }
+       if(sms_ops->set_cb_config) {
+               po->ops->set_cb_config = sms_ops->set_cb_config;
+       }
+       if(sms_ops->set_mem_status) {
+               po->ops->set_mem_status = sms_ops->set_mem_status;
+       }
+       if(sms_ops->get_pref_brearer) {
+               po->ops->get_pref_brearer = sms_ops->get_pref_brearer;
+       }
+       if(sms_ops->set_pref_brearer) {
+               po->ops->set_pref_brearer = sms_ops->set_pref_brearer;
+       }
+       if(sms_ops->set_delivery_report) {
+               po->ops->set_delivery_report = sms_ops->set_delivery_report;
+       }
+       if(sms_ops->set_msg_status) {
+               po->ops->set_msg_status = sms_ops->set_msg_status;
+       }
+       if(sms_ops->get_sms_params) {
+               po->ops->get_sms_params = sms_ops->get_sms_params;
+       }
+       if(sms_ops->set_sms_params) {
+               po->ops->set_sms_params = sms_ops->set_sms_params;
+       }
+       if(sms_ops->get_paramcnt) {
+               po->ops->get_paramcnt = sms_ops->get_paramcnt;
+       }
+       if(sms_ops->send_cdma_msg) {
+               po->ops->send_cdma_msg = sms_ops->send_cdma_msg;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -398,6 +458,24 @@ gboolean tcore_sms_set_ready_status(CoreObject *o, int status)
        return TRUE;
 }
 
+void tcore_sms_override_ops(CoreObject *o, struct tcore_sms_operations *sms_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SMS);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(sms_ops) {
+               _clone_sms_operations(po, sms_ops);
+       }
+
+       return;
+}
+
 CoreObject *tcore_sms_new(TcorePlugin *p, const char *name,
                struct tcore_sms_operations *ops, TcoreHal *hal)
 {
@@ -428,6 +506,22 @@ CoreObject *tcore_sms_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_sms_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_SMS);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_sms_free(CoreObject *o)
 {
        struct private_object_data *po = NULL;
index 1629815..3b0cd42 100644 (file)
@@ -49,6 +49,66 @@ struct private_object_data {
        struct tcore_ss_operations *ops;
 };
 
+static void _clone_ss_operations(struct private_object_data *po, struct tcore_ss_operations *ss_ops)
+{
+       if(ss_ops->barring_activate) {
+               po->ops->barring_activate = ss_ops->barring_activate;
+       }
+       if(ss_ops->barring_deactivate) {
+               po->ops->barring_deactivate = ss_ops->barring_deactivate;
+       }
+       if(ss_ops->barring_change_password) {
+               po->ops->barring_change_password = ss_ops->barring_change_password;
+       }
+       if(ss_ops->barring_get_status) {
+               po->ops->barring_get_status = ss_ops->barring_get_status;
+       }
+       if(ss_ops->forwarding_activate) {
+               po->ops->forwarding_activate = ss_ops->forwarding_activate;
+       }
+       if(ss_ops->forwarding_deactivate) {
+               po->ops->forwarding_deactivate = ss_ops->forwarding_deactivate;
+       }
+       if(ss_ops->forwarding_register) {
+               po->ops->forwarding_register = ss_ops->forwarding_register;
+       }
+       if(ss_ops->forwarding_deregister) {
+               po->ops->forwarding_deregister = ss_ops->forwarding_deregister;
+       }
+       if(ss_ops->forwarding_get_status) {
+               po->ops->forwarding_get_status = ss_ops->forwarding_get_status;
+       }
+       if(ss_ops->waiting_activate) {
+               po->ops->waiting_activate = ss_ops->waiting_activate;
+       }
+       if(ss_ops->waiting_deactivate) {
+               po->ops->waiting_deactivate = ss_ops->waiting_deactivate;
+       }
+       if(ss_ops->waiting_get_status) {
+               po->ops->waiting_get_status = ss_ops->waiting_get_status;
+       }
+       if(ss_ops->cli_activate) {
+               po->ops->cli_activate = ss_ops->cli_activate;
+       }
+       if(ss_ops->cli_deactivate) {
+               po->ops->cli_deactivate = ss_ops->cli_deactivate;
+       }
+       if(ss_ops->cli_get_status) {
+               po->ops->cli_get_status = ss_ops->cli_get_status;
+       }
+       if(ss_ops->send_ussd) {
+               po->ops->send_ussd = ss_ops->send_ussd;
+       }
+       if(ss_ops->set_aoc) {
+               po->ops->set_aoc = ss_ops->set_aoc;
+       }
+       if(ss_ops->get_aoc) {
+               po->ops->get_aoc = ss_ops->get_aoc;
+       }
+
+       return;
+}
+
 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
 {
        enum tcore_request_command command;
@@ -294,6 +354,23 @@ void tcore_ss_ussd_set_session_data(struct ussd_session* ussd_s, void *data, int
        }
 }
 
+void tcore_ss_override_ops(CoreObject *o, struct tcore_ss_operations *ss_ops)
+{
+       struct private_object_data *po = NULL;
+
+       CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SS);
+       
+       po = (struct private_object_data *)tcore_object_ref_object(o);
+       if (!po) {
+               return;
+       }
+
+       if(ss_ops) {
+               _clone_ss_operations(po, ss_ops);
+       }
+
+       return;
+}
 
 CoreObject *tcore_ss_new(TcorePlugin *p, const char *name,
                struct tcore_ss_operations *ops, TcoreHal *hal)
@@ -327,6 +404,22 @@ CoreObject *tcore_ss_new(TcorePlugin *p, const char *name,
        return o;
 }
 
+CoreObject *tcore_ss_clone(TcorePlugin *p, const char *name, TcoreHal *hal)
+{
+       CoreObject *o = NULL;
+
+       if (!p)
+               return NULL;
+
+       o = tcore_object_clone_template_object(p, name, CORE_OBJECT_TYPE_SS);
+       if (!o)
+               return NULL;
+
+       tcore_object_set_hal(o, hal);
+       
+       return o;
+}
+
 void tcore_ss_free(CoreObject *o)
 {
        CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_SS);
index da22e8b..a756d99 100644 (file)
@@ -25,6 +25,7 @@
 #include <glib.h>
 
 #include "tcore.h"
+#include "server.h"
 #include "plugin.h"
 #include "core_object.h"
 #include "hal.h"
@@ -191,6 +192,23 @@ CoreObject *tcore_object_clone(CoreObject *src, TcorePlugin *new_parent, const c
        return dest;
 }
 
+CoreObject *tcore_object_clone_template_object(TcorePlugin *p, const char *co_name, unsigned int co_type)
+{
+       CoreObject *co = NULL;
+       CoreObject *template_co = NULL;
+
+       template_co = tcore_server_find_template_object(tcore_plugin_ref_server(p), co_type);
+       if(!template_co) {
+               return NULL;
+       }
+       co = tcore_object_clone(template_co, p, co_name);
+       if(!co) {
+               return NULL;
+       }
+
+       return co;
+}
+
 const char *tcore_object_ref_name(CoreObject *co)
 {
        if (!co)
index 85e3d56..1cbb293 100644 (file)
@@ -46,6 +46,7 @@ struct tcore_server_type {
        GSList *communicators;
        GSList *storages;
        GSList *hals;
+       GSList *template_co;
        GSList *hook_list_request;
        GSList *hook_list_notification;
        TcorePlugin *default_plugin;
@@ -373,6 +374,57 @@ TcoreHal *tcore_server_find_hal(Server *s, const char *name)
        return NULL;
 }
 
+TReturn tcore_server_add_template_object(Server *s, CoreObject *template_co)
+{
+       GSList *list;
+       CoreObject *temp;
+
+       if (!s || !template_co)
+               return TCORE_RETURN_EINVAL;
+
+       for (list = s->template_co; list; list = list->next) {
+               temp = list->data;
+               if (!temp) {
+                       continue;
+               }
+
+               if (tcore_object_get_type(temp) == tcore_object_get_type(template_co)) {
+                       return TCORE_RETURN_EALREADY;
+               }
+       }
+
+       s->template_co = g_slist_insert(s->template_co, template_co, 0);
+
+       return TCORE_RETURN_SUCCESS;
+}
+
+GSList *tcore_server_ref_template_object(Server *s)
+{
+       if (!s)
+               return NULL;
+
+       return s->template_co;
+}
+
+CoreObject *tcore_server_find_template_object(Server *s, unsigned int type)
+{
+       GSList *list;
+       CoreObject *template_co;
+
+       for (list = s->template_co; list; list = list->next) {
+               template_co = list->data;
+               if (!template_co) {
+                       continue;
+               }
+
+               if (type == tcore_object_get_type(template_co)) {
+                       return template_co;
+               }
+       }
+
+       return NULL;
+}
+
 TReturn tcore_server_link_udev(Server *s, TcoreUdev *udev)
 {
        if (!s || !udev)