summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <stefan@datenfreihafen.org>2012-10-26 15:16:03 +0000
committerStefan Schmidt <stefan@datenfreihafen.org>2012-10-26 15:16:03 +0000
commita2218c1eb5ad7e5414b16f0eb079fac33464ad4d (patch)
tree91c0eb04f49ef70c7f4699246f0f736a7012821f
parent9bbe797e3321486bfddea585cb188023f3ff4b26 (diff)
PROTO/elocation: Add initial testing code for the Satellite interface.
Like NMEA and the upcoming POI interface this is only available in the Tizen version right now. Compile tested only at the moment. SVN revision: 78538
-rw-r--r--src/lib/Elocation.h1
-rw-r--r--src/lib/elocation.c106
2 files changed, 104 insertions, 3 deletions
diff --git a/src/lib/Elocation.h b/src/lib/Elocation.h
index bfef5ec..e8ba488 100644
--- a/src/lib/Elocation.h
+++ b/src/lib/Elocation.h
@@ -79,6 +79,7 @@ EAPI extern int ELOCATION_EVENT_VELOCITY; /**< Velocity changed */
79EAPI extern int ELOCATION_EVENT_GEOCODE; /**< Reply for geocode translation arrived */ 79EAPI extern int ELOCATION_EVENT_GEOCODE; /**< Reply for geocode translation arrived */
80EAPI extern int ELOCATION_EVENT_REVERSEGEOCODE; /**< Reply for geocode translation arrived */ 80EAPI extern int ELOCATION_EVENT_REVERSEGEOCODE; /**< Reply for geocode translation arrived */
81EAPI extern int ELOCATION_EVENT_NMEA; /**< NMEA update */ 81EAPI extern int ELOCATION_EVENT_NMEA; /**< NMEA update */
82EAPI extern int ELOCATION_EVENT_SATELLITE; /**< Satellite info changed */
82/**@}*/ 83/**@}*/
83 84
84/** 85/**
diff --git a/src/lib/elocation.c b/src/lib/elocation.c
index 941d3f2..2fef9b6 100644
--- a/src/lib/elocation.c
+++ b/src/lib/elocation.c
@@ -22,6 +22,7 @@ static EDBus_Proxy *meta_position = NULL;
22static EDBus_Proxy *meta_masterclient = NULL; 22static EDBus_Proxy *meta_masterclient = NULL;
23static EDBus_Proxy *meta_velocity = NULL; 23static EDBus_Proxy *meta_velocity = NULL;
24static EDBus_Proxy *meta_nmea = NULL; 24static EDBus_Proxy *meta_nmea = NULL;
25static EDBus_Proxy *meta_satellite = NULL;
25static EDBus_Proxy *geonames_geocode = NULL; 26static EDBus_Proxy *geonames_geocode = NULL;
26static EDBus_Proxy *geonames_rgeocode = NULL; 27static EDBus_Proxy *geonames_rgeocode = NULL;
27static Elocation_Address *address = NULL; 28static Elocation_Address *address = NULL;
@@ -43,11 +44,9 @@ EAPI int ELOCATION_EVENT_VELOCITY;
43EAPI int ELOCATION_EVENT_GEOCODE; 44EAPI int ELOCATION_EVENT_GEOCODE;
44EAPI int ELOCATION_EVENT_REVERSEGEOCODE; 45EAPI int ELOCATION_EVENT_REVERSEGEOCODE;
45EAPI int ELOCATION_EVENT_NMEA; 46EAPI int ELOCATION_EVENT_NMEA;
47EAPI int ELOCATION_EVENT_SATELLITE;
46 48
47/* FIXME: Signatures of Tizen interfaces 49/* FIXME: Signatures of Tizen interfaces
48 * Satellite: Method GetSatellite()->(iiiaia(iiii)) timestamp, satellite_used, satellite_visible, used_prn, sat_info
49 * Satellite: Method GetLastSatellite()->(iiiaia(iiii)) timestamp, satellite_used, satellite_visible, used_prn, sat_info
50 * Satellite: Signal SatelliteChanged->(iiiaia(iiii)) timestamp, satellite_used, satellite_visible, used_prn, sat_info
51 * Poi: Method SearchByPosition(sssidddd)->(ia(iiddddddsssssssssss) keyword, lang, country_code, limit, left, top, right, bottom -> count, landmark 50 * Poi: Method SearchByPosition(sssidddd)->(ia(iiddddddsssssssssss) keyword, lang, country_code, limit, left, top, right, bottom -> count, landmark
52 */ 51 */
53 52
@@ -458,6 +457,84 @@ nmea_signal_cb(void *data, const EDBus_Message *reply)
458} 457}
459 458
460static Eina_Bool 459static Eina_Bool
460unmarshall_satellite(const EDBus_Message *reply)
461{
462 int32_t timestamp = 0, satellite_used = 0, satellite_visible = 0;
463 int32_t snr = 0, elevation = 0, azimuth = 0, prn = 0, used_prn = 0;
464 EDBus_Message_Iter *sub_prn, *sub_info, *struct_info;
465
466 if (!edbus_message_arguments_get(reply, "iiiaia(iiii)", &timestamp, &satellite_used,
467 &satellite_visible, &sub_prn, &sub_info))
468 return EINA_FALSE;
469
470 while (edbus_message_iter_get_and_next(sub_prn, 'i', &used_prn))
471 {
472 DBG("Satellite used PRN %i", used_prn);
473 }
474
475 /* TODO re-check that the parameter ordering is what we expect */
476 while (edbus_message_iter_get_and_next(sub_info, 'r', &struct_info))
477 {
478 edbus_message_iter_arguments_get(struct_info, "iiii", &prn, &elevation, &azimuth, &snr);
479 DBG("Satellite info %i, %i, %i, %i", prn, elevation, azimuth, snr);
480 }
481
482 return EINA_TRUE;
483}
484
485static void
486satellite_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
487{
488 const char *err, *errmsg;
489
490 if (edbus_message_error_get(reply, &err, &errmsg))
491 {
492 ERR("Error: %s %s", err, errmsg);
493 return;
494 }
495
496 if (!unmarshall_satellite(reply))
497 {
498 ERR("Error: Unable to unmarshall satellite");
499 return;
500 }
501
502 ecore_event_add(ELOCATION_EVENT_SATELLITE, NULL, _dummy_free, NULL);
503}
504
505static void
506last_satellite_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
507{
508 const char *err, *errmsg;
509
510 if (edbus_message_error_get(reply, &err, &errmsg))
511 {
512 ERR("Error: %s %s", err, errmsg);
513 return;
514 }
515
516 if (!unmarshall_satellite(reply))
517 {
518 ERR("Error: Unable to unmarshall last satellite");
519 return;
520 }
521
522 ecore_event_add(ELOCATION_EVENT_SATELLITE, NULL, _dummy_free, NULL);
523}
524
525static void
526satellite_signal_cb(void *data, const EDBus_Message *reply)
527{
528 if (!unmarshall_satellite(reply))
529 {
530 ERR("Error: Unable to unmarshall satellite");
531 return;
532 }
533
534 ecore_event_add(ELOCATION_EVENT_SATELLITE, NULL, _dummy_free, NULL);
535}
536
537static Eina_Bool
461unmarshall_position(const EDBus_Message *reply) 538unmarshall_position(const EDBus_Message *reply)
462{ 539{
463 GeocluePositionFields fields; 540 GeocluePositionFields fields;
@@ -691,6 +768,13 @@ create_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
691 return; 768 return;
692 } 769 }
693 770
771 meta_satellite = edbus_proxy_get(obj_meta, GEOCLUE_SATELLITE_IFACE);
772 if (!meta_satellite)
773 {
774 ERR("Error: could not get proxy for satellite");
775 return;
776 }
777
694 /* Send Geoclue a set of requirements we have for the provider and start the address and position 778 /* Send Geoclue a set of requirements we have for the provider and start the address and position
695 * meta provider afterwards. After this we should be ready for operation. */ 779 * meta provider afterwards. After this we should be ready for operation. */
696 updates = EINA_FALSE; /* Especially the web providers do not offer updates */ 780 updates = EINA_FALSE; /* Especially the web providers do not offer updates */
@@ -755,6 +839,18 @@ create_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
755 return; 839 return;
756 } 840 }
757 841
842 if (!edbus_proxy_call(meta_satellite, "GetSatellite", satellite_cb, NULL, -1, ""))
843 {
844 ERR("Error: could not call GetSatellite");
845 return;
846 }
847
848 if (!edbus_proxy_call(meta_satellite, "GetLastSatellite", last_satellite_cb, NULL, -1, ""))
849 {
850 ERR("Error: could not call GetLastSatellite");
851 return;
852 }
853
758 if (!edbus_proxy_call(meta_masterclient, "GetAddressProvider", meta_address_provider_info_cb, NULL, -1, "")) 854 if (!edbus_proxy_call(meta_masterclient, "GetAddressProvider", meta_address_provider_info_cb, NULL, -1, ""))
759 { 855 {
760 ERR("Error: could not call GetAddressProvider"); 856 ERR("Error: could not call GetAddressProvider");
@@ -772,6 +868,7 @@ create_cb(void *data, const EDBus_Message *reply, EDBus_Pending *pending)
772 edbus_proxy_signal_handler_add(meta_geoclue, "StatusChanged", status_signal_cb, NULL); 868 edbus_proxy_signal_handler_add(meta_geoclue, "StatusChanged", status_signal_cb, NULL);
773 edbus_proxy_signal_handler_add(meta_velocity, "VelocityChanged", velocity_signal_cb, NULL); 869 edbus_proxy_signal_handler_add(meta_velocity, "VelocityChanged", velocity_signal_cb, NULL);
774 edbus_proxy_signal_handler_add(meta_nmea, "NmeaChanged", nmea_signal_cb, NULL); 870 edbus_proxy_signal_handler_add(meta_nmea, "NmeaChanged", nmea_signal_cb, NULL);
871 edbus_proxy_signal_handler_add(meta_satellite, "SatelliteChanged", satellite_signal_cb, NULL);
775} 872}
776 873
777static void 874static void
@@ -1029,6 +1126,9 @@ elocation_init()
1029 if (ELOCATION_EVENT_NMEA == 0) 1126 if (ELOCATION_EVENT_NMEA == 0)
1030 ELOCATION_EVENT_NMEA = ecore_event_type_new(); 1127 ELOCATION_EVENT_NMEA = ecore_event_type_new();
1031 1128
1129 if (ELOCATION_EVENT_SATELLITE == 0)
1130 ELOCATION_EVENT_SATELLITE = ecore_event_type_new();
1131
1032 obj_master= edbus_object_get(conn, GEOCLUE_DBUS_NAME, GEOCLUE_OBJECT_PATH); 1132 obj_master= edbus_object_get(conn, GEOCLUE_DBUS_NAME, GEOCLUE_OBJECT_PATH);
1033 if (!obj_master) 1133 if (!obj_master)
1034 { 1134 {