summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2013-03-14 16:09:39 +0000
committerStefan Schmidt <s.schmidt@samsung.com>2013-03-14 16:09:39 +0000
commit89e8e6087a608483e15be7511ec6c0fa69bb93b2 (patch)
tree0c85c205697dd092011f09e8ee5c52c6767901f7
parent66e6b5830edeada4c00355a09c742cf0ce221546 (diff)
elocation: Pass providers around to rely less on globals
-rw-r--r--src/lib/elocation.c64
1 files changed, 40 insertions, 24 deletions
diff --git a/src/lib/elocation.c b/src/lib/elocation.c
index 0bdb2ee..2b6fe50 100644
--- a/src/lib/elocation.c
+++ b/src/lib/elocation.c
@@ -83,6 +83,9 @@ static void
83meta_address_provider_info_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending) 83meta_address_provider_info_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
84{ 84{
85 const char *err, *errmsg; 85 const char *err, *errmsg;
86 Elocation_Provider *addr_provider;
87
88 addr_provider = data;
86 89
87 if (edbus_message_error_get(reply, &err, &errmsg)) 90 if (edbus_message_error_get(reply, &err, &errmsg))
88 { 91 {
@@ -90,22 +93,25 @@ meta_address_provider_info_cb(void *data, const EDBus_Message *reply, EDBus_Pend
90 return; 93 return;
91 } 94 }
92 95
93 if (!unmarshall_provider(reply, address_provider)) 96 if (!unmarshall_provider(reply, addr_provider))
94 { 97 {
95 ERR("Error: Unable to unmarshall address provider"); 98 ERR("Error: Unable to unmarshall address provider");
96 return; 99 return;
97 } 100 }
98 101
99 DBG("Meta address provider name: %s, %s, %s, %s", address_provider->name, 102 DBG("Meta address provider name: %s, %s, %s, %s", addr_provider->name,
100 address_provider->description, 103 addr_provider->description,
101 address_provider->service, 104 addr_provider->service,
102 address_provider->path); 105 addr_provider->path);
103} 106}
104 107
105static void 108static void
106meta_position_provider_info_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending) 109meta_position_provider_info_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
107{ 110{
108 const char *err, *errmsg; 111 const char *err, *errmsg;
112 Elocation_Provider *pos_provider;
113
114 pos_provider = data;
109 115
110 if (edbus_message_error_get(reply, &err, &errmsg)) 116 if (edbus_message_error_get(reply, &err, &errmsg))
111 { 117 {
@@ -113,46 +119,52 @@ meta_position_provider_info_cb(void *data, const EDBus_Message *reply, EDBus_Pen
113 return; 119 return;
114 } 120 }
115 121
116 if (!unmarshall_provider(reply, position_provider)) 122 if (!unmarshall_provider(reply, pos_provider))
117 { 123 {
118 ERR("Error: Unable to unmarshall position provider"); 124 ERR("Error: Unable to unmarshall position provider");
119 return; 125 return;
120 } 126 }
121 127
122 DBG("Meta position provider name: %s, %s, %s, %s", position_provider->name, 128 DBG("Meta position provider name: %s, %s, %s, %s", pos_provider->name,
123 position_provider->description, 129 pos_provider->description,
124 position_provider->service, 130 pos_provider->service,
125 position_provider->path); 131 pos_provider->path);
126} 132}
127 133
128static void 134static void
129meta_address_provider_info_signal_cb(void *data, const EDBus_Message *reply) 135meta_address_provider_info_signal_cb(void *data, const EDBus_Message *reply)
130{ 136{
131 if (!unmarshall_provider(reply, address_provider)) 137 Elocation_Provider *addr_provider;
138 addr_provider = data;
139
140 if (!unmarshall_provider(reply, addr_provider))
132 { 141 {
133 ERR("Error: Unable to unmarshall address provider"); 142 ERR("Error: Unable to unmarshall address provider");
134 return; 143 return;
135 } 144 }
136 145
137 DBG("Meta address provider name changed: %s, %s, %s, %s", address_provider->name, 146 DBG("Meta address provider name changed: %s, %s, %s, %s", addr_provider->name,
138 address_provider->description, 147 addr_provider->description,
139 address_provider->service, 148 addr_provider->service,
140 address_provider->path); 149 addr_provider->path);
141} 150}
142 151
143static void 152static void
144meta_position_provider_info_signal_cb(void *data, const EDBus_Message *reply) 153meta_position_provider_info_signal_cb(void *data, const EDBus_Message *reply)
145{ 154{
146 if (!unmarshall_provider(reply, position_provider)) 155 Elocation_Provider *pos_provider;
156 pos_provider = data;
157
158 if (!unmarshall_provider(reply, pos_provider))
147 { 159 {
148 ERR("Error: Unable to unmarshall position provider"); 160 ERR("Error: Unable to unmarshall position provider");
149 return; 161 return;
150 } 162 }
151 163
152 DBG("Meta position provider name changed: %s, %s, %s, %s", position_provider->name, 164 DBG("Meta position provider name changed: %s, %s, %s, %s", pos_provider->name,
153 position_provider->description, 165 pos_provider->description,
154 position_provider->service, 166 pos_provider->service,
155 position_provider->path); 167 pos_provider->path);
156} 168}
157 169
158/* Receive and unmarshall a reverse GeoCode message. The dict can contain a 170/* Receive and unmarshall a reverse GeoCode message. The dict can contain a
@@ -872,8 +884,10 @@ create_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
872 min_time = 0; /* Minimal times between updates (no implemented yet) */ 884 min_time = 0; /* Minimal times between updates (no implemented yet) */
873 resources = ELOCATION_RESOURCE_ALL; 885 resources = ELOCATION_RESOURCE_ALL;
874 886
875 edbus_proxy_signal_handler_add(meta_masterclient, "AddressProviderChanged", meta_address_provider_info_signal_cb, NULL); 887 edbus_proxy_signal_handler_add(meta_masterclient, "AddressProviderChanged",
876 edbus_proxy_signal_handler_add(meta_masterclient, "PositionProviderChanged", meta_position_provider_info_signal_cb, NULL); 888 meta_address_provider_info_signal_cb, address_provider);
889 edbus_proxy_signal_handler_add(meta_masterclient, "PositionProviderChanged",
890 meta_position_provider_info_signal_cb, position_provider);
877 891
878 if (!edbus_proxy_call(meta_masterclient, "SetRequirements", _dummy_cb, NULL, -1, "iibi", 892 if (!edbus_proxy_call(meta_masterclient, "SetRequirements", _dummy_cb, NULL, -1, "iibi",
879 accur_level, min_time, updates, resources)) 893 accur_level, min_time, updates, resources))
@@ -942,13 +956,15 @@ create_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
942 return; 956 return;
943 } 957 }
944 958
945 if (!edbus_proxy_call(meta_masterclient, "GetAddressProvider", meta_address_provider_info_cb, NULL, -1, "")) 959 if (!edbus_proxy_call(meta_masterclient, "GetAddressProvider", meta_address_provider_info_cb,
960 address_provider, -1, ""))
946 { 961 {
947 ERR("Error: could not call GetAddressProvider"); 962 ERR("Error: could not call GetAddressProvider");
948 return; 963 return;
949 } 964 }
950 965
951 if (!edbus_proxy_call(meta_masterclient, "GetPositionProvider", meta_position_provider_info_cb, NULL, -1, "")) 966 if (!edbus_proxy_call(meta_masterclient, "GetPositionProvider", meta_position_provider_info_cb,
967 position_provider, -1, ""))
952 { 968 {
953 ERR("Error: could not call GetPositionProvider"); 969 ERR("Error: could not call GetPositionProvider");
954 return; 970 return;