~device_context_provider();
bool init();
- bool is_supported(const char* subject, const char* zone);
- int subscribe(const char* subject, ctx::json option, ctx::json* request_result, const char* zone);
- int unsubscribe(const char* subject, ctx::json option, const char* zone);
- int read(const char* subject, ctx::json option, ctx::json* request_result, const char* zone);
- int write(const char* subject, ctx::json data, ctx::json* request_result, const char* zone);
+ bool is_supported(const char* subject);
+ int subscribe(const char* subject, ctx::json option, ctx::json* request_result);
+ int unsubscribe(const char* subject, ctx::json option);
+ int read(const char* subject, ctx::json option, ctx::json* request_result);
+ int write(const char* subject, ctx::json data, ctx::json* request_result);
};
}
#define CREATE_SUB_PROVIDER(subject, subprovider) do { \
ctx::sub_provider_base *sub = new ctx::subprovider(); \
- if (sub->is_supported(subject, NULL)) { \
+ if (sub->is_supported(subject)) { \
subject_map[(subject)] = sub; \
} else { \
_E("%s is not supported", subject); \
return true;
}
-bool ctx::device_context_provider::is_supported(const char* subject, const char* zone)
+bool ctx::device_context_provider::is_supported(const char* subject)
{
subject_map_t::iterator it = subject_map.find(subject);
if (it != subject_map.end())
- return it->second->is_supported(subject, zone);
+ return it->second->is_supported(subject);
return false;
}
-int ctx::device_context_provider::subscribe(const char* subject, ctx::json option, ctx::json* request_result, const char* zone)
+int ctx::device_context_provider::subscribe(const char* subject, ctx::json option, ctx::json* request_result)
{
- _D("Starts to publish '%s' on '%s'", subject, zone);
+ _D("Starts to publish '%s'", subject);
subject_map_t::iterator it = subject_map.find(subject);
if (it != subject_map.end())
- return it->second->subscribe(subject, zone);
+ return it->second->subscribe(subject);
return ERR_NOT_SUPPORTED;
}
-int ctx::device_context_provider::unsubscribe(const char* subject, ctx::json option, const char* zone)
+int ctx::device_context_provider::unsubscribe(const char* subject, ctx::json option)
{
- _D("Stops publishing '%s' on '%s'", subject, zone);
+ _D("Stops publishing '%s'", subject);
subject_map_t::iterator it = subject_map.find(subject);
if (it != subject_map.end())
- return it->second->unsubscribe(subject, zone);
+ return it->second->unsubscribe(subject);
return ERR_NOT_SUPPORTED;
}
-int ctx::device_context_provider::read(const char* subject, ctx::json option, ctx::json* request_result, const char* zone)
+int ctx::device_context_provider::read(const char* subject, ctx::json option, ctx::json* request_result)
{
- _D("Reads '%s' on '%s'", subject, zone);
+ _D("Reads '%s'", subject);
subject_map_t::iterator it = subject_map.find(subject);
if (it != subject_map.end())
- return it->second->read(subject, zone);
+ return it->second->read(subject);
return ERR_NOT_SUPPORTED;
}
-int ctx::device_context_provider::write(const char* subject, ctx::json data, ctx::json* request_result, const char* zone)
+int ctx::device_context_provider::write(const char* subject, ctx::json data, ctx::json* request_result)
{
return ERR_NOT_SUPPORTED;
}
struct activity_recog_s {
const char *name;
activity_h handle;
- ctx::string_set_t client_zone;
activity_recog_s() : name(NULL), handle(NULL) {}
};
if (activity_recog[i].handle == NULL) continue;
activity_release(activity_recog[i].handle);
activity_recog[i].handle = NULL;
- activity_recog[i].client_zone.clear();
}
}
break;
}
- publish(activity_recog[activity].name, ERR_NONE, data_read, activity_recog[activity].client_zone);
+ publish(activity_recog[activity].name, ERR_NONE, data_read);
}
-int ctx::device_status_activity::subscribe(const char* subject, const char* zone)
+int ctx::device_status_activity::subscribe(const char* subject)
{
int act_num = get_activity_id(subject);
IF_FAIL_RETURN(act_num > 0, ERR_INVALID_PARAMETER);
activity_recog[act_num].handle = handle;
CATCH:
- activity_recog[act_num].client_zone.insert(zone);
return ERR_NONE;
}
-int ctx::device_status_activity::unsubscribe(const char* subject, const char* zone)
+int ctx::device_status_activity::unsubscribe(const char* subject)
{
int act_num = get_activity_id(subject);
IF_FAIL_RETURN(act_num > 0, ERR_INVALID_PARAMETER);
- activity_recog[act_num].client_zone.erase(zone);
- IF_FAIL_RETURN(activity_recog[act_num].client_zone.empty(), ERR_NONE);
+ IF_FAIL_RETURN(activity_recog[act_num].handle, ERR_NONE);
_D("Stop monitoring %s", subject);
return ERR_NONE;
}
-bool ctx::device_status_activity::is_supported(const char* subject, const char* zone)
+bool ctx::device_status_activity::is_supported(const char* subject)
{
bool supported = false;
activity_is_supported(static_cast<activity_type_e>(get_activity_id(subject)), &supported);
device_status_activity();
~device_status_activity();
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- bool is_supported(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ bool is_supported(const char* subject);
private:
void handle_event(activity_type_e activity, const activity_data_h data, double timestamp);
}
}
+ctx::device_status_battery_level::device_status_battery_level()
+ : being_subscribed(false)
+{
+}
+
void ctx::device_status_battery_level::update_cb(device_callback_e device_type, void* value, void* user_data)
{
IF_FAIL_VOID(device_type == DEVICE_CALLBACK_BATTERY_LEVEL);
data_read.set(NULL, DEVICE_ST_IS_CHARGING, charging_state ? DEVICE_ST_TRUE : DEVICE_ST_FALSE);
- publish(DEVICE_ST_SUBJ_BATTERY, ERR_NONE, data_read, client_zone);
+ publish(DEVICE_ST_SUBJ_BATTERY, ERR_NONE, data_read);
}
-int ctx::device_status_battery_level::subscribe(const char* subject, const char* zone)
+int ctx::device_status_battery_level::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
int ret = device_add_callback(DEVICE_CALLBACK_BATTERY_LEVEL, update_cb, this);
IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED);
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::device_status_battery_level::unsubscribe(const char* subject, const char* zone)
+int ctx::device_status_battery_level::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
-
+ being_subscribed = false;
int ret = device_remove_callback(DEVICE_CALLBACK_BATTERY_LEVEL, update_cb);
IF_FAIL_RETURN(ret == DEVICE_ERROR_NONE, ERR_OPERATION_FAILED);
return ERR_NONE;
}
-int ctx::device_status_battery_level::read(const char* subject, const char* zone)
+int ctx::device_status_battery_level::read(const char* subject)
{
device_battery_level_e level;
ctx::json data_read;
data_read.set(NULL, DEVICE_ST_IS_CHARGING, charging_state ? DEVICE_ST_TRUE : DEVICE_ST_FALSE);
- ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, data_read, zone);
+ ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_BATTERY, NULL, ERR_NONE, data_read);
return ERR_NONE;
}
class device_status_battery_level : public sub_provider_base {
public:
+ device_status_battery_level();
~device_status_battery_level(){}
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- int read(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ int read(const char* subject);
private:
- string_set_t client_zone;
+ bool being_subscribed;
void handle_update(device_callback_e device_type, void* value);
static void update_cb(device_callback_e device_type, void* value, void* user_data);
#define MAX_HANDLING_COUNT 3
ctx::device_status_headphone::device_status_headphone()
- : connected(false)
+ : being_subscribed(false)
+ , connected(false)
, audio_jack_state(RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED)
, bt_audio_state(false)
, bt_audio_callback_on(false)
{
}
-int ctx::device_status_headphone::subscribe(const char* subject, const char* zone)
+int ctx::device_status_headphone::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
connected = get_current_status();
// Wired headphone
set_bt_audio_callback();
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::device_status_headphone::unsubscribe(const char* subject, const char* zone)
+int ctx::device_status_headphone::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
+ being_subscribed = false;
runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS);
unset_bt_audio_callback();
return ERR_NONE;
}
-int ctx::device_status_headphone::read(const char* subject, const char* zone)
+int ctx::device_status_headphone::read(const char* subject)
{
- if (client_zone.empty())
+ if (!being_subscribed)
connected = get_current_status();
json data;
generate_data_packet(data);
- ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data, zone);
+ ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_HEADPHONE, NULL, ERR_NONE, data);
return ERR_NONE;
}
ctx::json data;
generate_data_packet(data);
- publish(DEVICE_ST_SUBJ_HEADPHONE, ERR_NONE, data, client_zone);
+ publish(DEVICE_ST_SUBJ_HEADPHONE, ERR_NONE, data);
return true;
}
device_status_headphone();
~device_status_headphone() {}
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- int read(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ int read(const char* subject);
private:
- string_set_t client_zone;
-
+ bool being_subscribed;
bool connected;
int audio_jack_state;
bool bt_audio_state;
#include "psmode.h"
+ctx::device_status_power_saving_mode::device_status_power_saving_mode()
+ : being_subscribed(false)
+{
+}
+
void ctx::device_status_power_saving_mode::update_cb(keynode_t *node, void* user_data)
{
device_status_power_saving_mode *instance = static_cast<device_status_power_saving_mode*>(user_data);
data_read.set(NULL, DEVICE_ST_IS_ENABLED, status == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE);
- publish(DEVICE_ST_SUBJ_POWER_SAVING_MODE, ERR_NONE, data_read, client_zone);
+ publish(DEVICE_ST_SUBJ_POWER_SAVING_MODE, ERR_NONE, data_read);
}
-int ctx::device_status_power_saving_mode::subscribe(const char* subject, const char* zone)
+int ctx::device_status_power_saving_mode::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
int ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE, update_cb, this);
IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED);
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::device_status_power_saving_mode::unsubscribe(const char* subject, const char* zone)
+int ctx::device_status_power_saving_mode::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
+ being_subscribed = false;
int ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE, update_cb);
IF_FAIL_RETURN(ret == VCONF_OK, ERR_OPERATION_FAILED);
return ERR_NONE;
}
-int ctx::device_status_power_saving_mode::read(const char* subject, const char* zone)
+int ctx::device_status_power_saving_mode::read(const char* subject)
{
int mode;
int ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &mode);
ctx::json data_read;
data_read.set(NULL, DEVICE_ST_IS_ENABLED, mode == 0 ? DEVICE_ST_FALSE : DEVICE_ST_TRUE);
- ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_POWER_SAVING_MODE, NULL, ERR_NONE, data_read, zone);
+ ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_POWER_SAVING_MODE, NULL, ERR_NONE, data_read);
return ERR_NONE;
}
class device_status_power_saving_mode : public sub_provider_base {
public:
+ device_status_power_saving_mode();
~device_status_power_saving_mode(){}
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- int read(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ int read(const char* subject);
private:
- string_set_t client_zone;
+ bool being_subscribed;
void handle_update(keynode_t *node);
static void update_cb(keynode_t *node, void* user_data);
#include "base_rtinfo.h"
ctx::device_status_runtime_info::device_status_runtime_info(runtime_info_key_e key)
- : info_key (key)
+ : being_subscribed(false)
+ , info_key(key)
{
}
instance->handle_update();
}
-int ctx::device_status_runtime_info::subscribe(const char* subject, const char* zone)
+int ctx::device_status_runtime_info::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
int ret = runtime_info_set_changed_cb(info_key, update_cb, this);
IF_FAIL_RETURN(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED);
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::device_status_runtime_info::unsubscribe(const char* subject, const char* zone)
+int ctx::device_status_runtime_info::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
+ being_subscribed = false;
int ret = runtime_info_unset_changed_cb(info_key);
IF_FAIL_RETURN(ret == RUNTIME_INFO_ERROR_NONE, ERR_OPERATION_FAILED);
device_status_runtime_info(runtime_info_key_e key);
virtual ~device_status_runtime_info(){}
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- virtual int read(const char* subject, const char* zone) = 0;
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ virtual int read(const char* subject) = 0;
protected:
- string_set_t client_zone;
+ bool being_subscribed;
runtime_info_key_e info_key;
static void update_cb(runtime_info_key_e runtime_key, void* user_data);
ctx::json data_read;
data_read.set(NULL, DEVICE_ST_IS_CONNECTED, charger_status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE);
- publish(DEVICE_ST_SUBJ_CHARGER, ERR_NONE, data_read, client_zone);
+ publish(DEVICE_ST_SUBJ_CHARGER, ERR_NONE, data_read);
}
-int ctx::device_status_charger::read(const char* subject, const char* zone)
+int ctx::device_status_charger::read(const char* subject)
{
bool charger_status = false;
ctx::json data_read;
data_read.set(NULL, DEVICE_ST_IS_CONNECTED, charger_status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE);
- ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, data_read, zone);
+ ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_CHARGER, NULL, ERR_NONE, data_read);
return ERR_NONE;
}
device_status_charger() : device_status_runtime_info(RUNTIME_INFO_KEY_CHARGER_CONNECTED) {}
~device_status_charger(){}
- int read(const char* subject, const char* zone);
+ int read(const char* subject);
private:
void handle_update();
data_read.set(NULL, DEVICE_ST_STATE, state_str);
- publish(DEVICE_ST_SUBJ_GPS, ERR_NONE, data_read, client_zone);
+ publish(DEVICE_ST_SUBJ_GPS, ERR_NONE, data_read);
}
-int ctx::device_status_gps::read(const char* subject, const char* zone)
+int ctx::device_status_gps::read(const char* subject)
{
int gps_status;
ctx::json data_read;
data_read.set(NULL, DEVICE_ST_STATE, state_str);
- ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, data_read, zone);
+ ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_GPS, NULL, ERR_NONE, data_read);
return ERR_NONE;
}
-bool ctx::device_status_gps::is_supported(const char* subject, const char* zone)
+bool ctx::device_status_gps::is_supported(const char* subject)
{
bool supported = false;
device_status_gps() : device_status_runtime_info(RUNTIME_INFO_KEY_GPS_STATUS) {}
~device_status_gps(){}
- int read(const char* subject, const char* zone);
- bool is_supported(const char* subject, const char* zone);
+ int read(const char* subject);
+ bool is_supported(const char* subject);
private:
void handle_update();
ctx::json data_read;
data_read.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE);
- publish(DEVICE_ST_SUBJ_USB, ERR_NONE, data_read, client_zone);
+ publish(DEVICE_ST_SUBJ_USB, ERR_NONE, data_read);
}
-int ctx::device_status_usb::read(const char* subject, const char* zone)
+int ctx::device_status_usb::read(const char* subject)
{
bool status = false;
ctx::json data_read;
data_read.set(NULL, DEVICE_ST_IS_CONNECTED, status ? DEVICE_ST_TRUE : DEVICE_ST_FALSE);
- ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_USB, NULL, ERR_NONE, data_read, zone);
+ ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_USB, NULL, ERR_NONE, data_read);
return ERR_NONE;
}
-bool ctx::device_status_usb::is_supported(const char* subject, const char* zone)
+bool ctx::device_status_usb::is_supported(const char* subject)
{
bool supported = false;
device_status_usb() : device_status_runtime_info(RUNTIME_INFO_KEY_USB_CONNECTED) {}
~device_status_usb(){}
- int read(const char* subject, const char* zone);
- bool is_supported(const char* subject, const char* zone);
+ int read(const char* subject);
+ bool is_supported(const char* subject);
private:
void handle_update();
#include "wifi.h"
ctx::device_status_wifi::device_status_wifi()
- : last_state(_UNKNOWN)
+ : being_subscribed(false)
+ , last_state(_UNKNOWN)
, is_initialized(false)
, is_activated(false)
{
}
-bool ctx::device_status_wifi::is_supported(const char* subject, const char* zone)
+bool ctx::device_status_wifi::is_supported(const char* subject)
{
bool supported = false;
return true;
}
-int ctx::device_status_wifi::read(const char* subject, const char* zone)
+int ctx::device_status_wifi::read(const char* subject)
{
IF_FAIL_RETURN(get_current_state(), ERR_OPERATION_FAILED);
ctx::json data_read;
if (get_response_packet(data_read)) {
- ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, data_read, zone);
+ ctx::context_manager::reply_to_read(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, data_read);
return ERR_NONE;
}
is_initialized = false;
}
-int ctx::device_status_wifi::subscribe(const char* subject, const char* zone)
+int ctx::device_status_wifi::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
IF_FAIL_RETURN(start_monitor(), ERR_OPERATION_FAILED);
if (!get_current_state()) {
stop_monitor();
}
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::device_status_wifi::unsubscribe(const char* subject, const char* zone)
+int ctx::device_status_wifi::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
+ being_subscribed = false;
stop_monitor();
return ERR_NONE;
ctx::json data;
if (get_response_packet(data))
- publish(DEVICE_ST_SUBJ_WIFI, ERR_NONE, data, client_zone);
+ publish(DEVICE_ST_SUBJ_WIFI, ERR_NONE, data);
}
}
device_status_wifi();
~device_status_wifi(){}
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- int read(const char* subject, const char* zone);
- bool is_supported(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ int read(const char* subject);
+ bool is_supported(const char* subject);
private:
enum _state_e {
_CONNECTED,
};
- string_set_t client_zone;
-
+ bool being_subscribed;
int last_state;
bool is_initialized;
bool is_activated;
}
ctx::social_status_call::social_status_call()
+ : being_subscribed(false)
{
tapi_handle = NULL;
}
break;
}
- publish(SOCIAL_ST_SUBJ_CALL, ERR_NONE, data, client_zone);
+ publish(SOCIAL_ST_SUBJ_CALL, ERR_NONE, data);
}
bool ctx::social_status_call::init_telephony()
return true;
}
-int ctx::social_status_call::subscribe(const char* subject, const char* zone)
+int ctx::social_status_call::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
bool ret = set_callback();
IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED);
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::social_status_call::unsubscribe(const char* subject, const char* zone)
+int ctx::social_status_call::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
-
+ being_subscribed = false;
unset_callback();
return ERR_NONE;
}
return true;
}
-int ctx::social_status_call::read(const char* subject, const char* zone)
+int ctx::social_status_call::read(const char* subject)
{
bool temporary_handle = false;
if (!telephony_initialized) {
release_telephony();
if (ret) {
- ctx::context_manager::reply_to_read(SOCIAL_ST_SUBJ_CALL, NULL, ERR_NONE, data, zone);
+ ctx::context_manager::reply_to_read(SOCIAL_ST_SUBJ_CALL, NULL, ERR_NONE, data);
return ERR_NONE;
}
return ERR_OPERATION_FAILED;
}
-bool ctx::social_status_call::is_supported(const char* subject, const char* zone)
+bool ctx::social_status_call::is_supported(const char* subject)
{
bool supported = false;
int ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &supported);
social_status_call();
~social_status_call();
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- int read(const char* subject, const char* zone);
- bool is_supported(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ int read(const char* subject);
+ bool is_supported(const char* subject);
private:
telephony_handle_list_s handle_list;
- string_set_t client_zone;
+ bool being_subscribed;
bool init_telephony();
void release_telephony();
#include <dbus_server.h>
#include "email.h"
+ctx::social_status_email::social_status_email()
+ : being_subscribed(false)
+{
+}
void ctx::social_status_email::on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param)
{
_D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", sub_type, gi1, gc, gi2, gi3);
ctx::json data_updated;
data_updated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED);
- publish(SOCIAL_ST_SUBJ_EMAIL, ERR_NONE, data_updated, client_zone);
+ publish(SOCIAL_ST_SUBJ_EMAIL, ERR_NONE, data_updated);
} else if (sub_type == NOTI_SEND_FINISH) {
_D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", sub_type, gi1, gc, gi2, gi3);
ctx::json data_updated;
data_updated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_SENT);
- publish(SOCIAL_ST_SUBJ_EMAIL, ERR_NONE, data_updated, client_zone);
+ publish(SOCIAL_ST_SUBJ_EMAIL, ERR_NONE, data_updated);
}
}
-int ctx::social_status_email::subscribe(const char* subject, const char* zone)
+int ctx::social_status_email::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
dbus_signal_id = ctx::dbus_server::signal_subscribe(NULL, NULL, "User.Email.NetworkStatus", "email", this);
IF_FAIL_RETURN_TAG(dbus_signal_id >= 0, ERR_OPERATION_FAILED, _E, "Email dbus signal subscription failed");
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::social_status_email::unsubscribe(const char* subject, const char* zone)
+int ctx::social_status_email::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
-
+ being_subscribed = false;
ctx::dbus_server::signal_unsubscribe(dbus_signal_id);
return ERR_NONE;
}
class social_status_email : public sub_provider_base, public dbus_listener_iface {
public:
- social_status_email() {}
+ social_status_email();
~social_status_email() {}
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
void on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param);
private:
int64_t dbus_signal_id;
- string_set_t client_zone;
+ bool being_subscribed;
};
}
ctx::social_status_message::social_status_message()
: message_handle(NULL)
+ , being_subscribed(false)
{
}
data.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED);
data.set(NULL, SOCIAL_ST_ADDRESS, address);
- publish(SOCIAL_ST_SUBJ_MESSAGE, ERR_NONE, data, client_zone);
+ publish(SOCIAL_ST_SUBJ_MESSAGE, ERR_NONE, data);
}
bool ctx::social_status_message::set_callback()
message_handle = NULL;
}
-int ctx::social_status_message::subscribe(const char* subject, const char* zone)
+int ctx::social_status_message::subscribe(const char* subject)
{
- if (client_zone.empty()) {
+ if (!being_subscribed) {
bool ret = set_callback();
IF_FAIL_RETURN(ret, ERR_OPERATION_FAILED);
}
- client_zone.insert(zone);
+ being_subscribed = true;
return ERR_NONE;
}
-int ctx::social_status_message::unsubscribe(const char* subject, const char* zone)
+int ctx::social_status_message::unsubscribe(const char* subject)
{
- client_zone.erase(zone);
- IF_FAIL_RETURN(client_zone.empty(), ERR_NONE);
-
+ being_subscribed = false;
unset_callback();
return ERR_NONE;
}
-bool ctx::social_status_message::is_supported(const char* subject, const char* zone)
+bool ctx::social_status_message::is_supported(const char* subject)
{
bool supported = false;
int ret = system_info_get_platform_bool("tizen.org/feature/network.telephony", &supported);
social_status_message();
~social_status_message() {}
- int subscribe(const char* subject, const char* zone);
- int unsubscribe(const char* subject, const char* zone);
- bool is_supported(const char* subject, const char* zone);
+ int subscribe(const char* subject);
+ int unsubscribe(const char* subject);
+ bool is_supported(const char* subject);
private:
msg_handle_t message_handle;
- string_set_t client_zone;
+ bool being_subscribed;
bool set_callback();
void unset_callback();
#include "sub_provider_base.h"
-int ctx::sub_provider_base::subscribe(const char* subject, const char* zone)
+int ctx::sub_provider_base::subscribe(const char* subject)
{
return ERR_NOT_SUPPORTED;
}
-int ctx::sub_provider_base::unsubscribe(const char* subject, const char* zone)
+int ctx::sub_provider_base::unsubscribe(const char* subject)
{
return ERR_NOT_SUPPORTED;
}
-int ctx::sub_provider_base::read(const char* subject, const char* zone)
+int ctx::sub_provider_base::read(const char* subject)
{
return ERR_NOT_SUPPORTED;
}
-bool ctx::sub_provider_base::is_supported(const char* subject, const char* zone)
+bool ctx::sub_provider_base::is_supported(const char* subject)
{
// Generally, if a sub-analyzer is implemented by inheriting this class, "subject" is supported.
return true;
}
-void ctx::sub_provider_base::publish(const char* subject, int error, ctx::json data, string_set_t& zone_list)
+void ctx::sub_provider_base::publish(const char* subject, int error, ctx::json data)
{
ctx::json option;
- for (string_set_t::iterator it = zone_list.begin(); it != zone_list.end(); ++it) {
- _D("Publishing '%s' on '%s'", subject, (*it).c_str());
- ctx::context_manager::publish(subject, option, error, data, (*it).c_str());
- }
+ _D("Publishing '%s'", subject);
+ ctx::context_manager::publish(subject, option, error, data);
}
namespace ctx {
- typedef std::set<std::string> string_set_t;
-
class sub_provider_base {
public:
sub_provider_base(){}
virtual ~sub_provider_base(){}
- virtual int subscribe(const char* subject, const char* zone);
- virtual int unsubscribe(const char* subject, const char* zone);
- virtual int read(const char* subject, const char* zone);
- virtual bool is_supported(const char* subject, const char* zone);
+ virtual int subscribe(const char* subject);
+ virtual int unsubscribe(const char* subject);
+ virtual int read(const char* subject);
+ virtual bool is_supported(const char* subject);
protected:
- void publish(const char* subject, int error, ctx::json data, string_set_t& zone_list);
+ void publish(const char* subject, int error, ctx::json data);
};
}