2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <email-api-etc.h>
22 SocialStatusEmail::SocialStatusEmail() :
23 BasicProvider(SOCIAL_ST_SUBJ_EMAIL),
25 __dbusWatcher(DBusType::SESSION)
29 SocialStatusEmail::~SocialStatusEmail()
33 bool SocialStatusEmail::isSupported()
35 return getSystemInfoBool("tizen.org/feature/network.telephony");
38 void SocialStatusEmail::submitTriggerItem()
40 registerTriggerItem(OPS_SUBSCRIBE,
42 "\"Event\":{\"type\":\"string\",\"values\":[\"Received\",\"Sent\"]}"
47 void SocialStatusEmail::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param)
51 const gchar *gc = NULL;
55 g_variant_get(param, "(ii&sii)", &subType, &gi1, &gc, &gi2, &gi3);
57 if (subType == NOTI_DOWNLOAD_FINISH) {
58 //TODO: Check if this signal actually means that there are new mails
59 _D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", subType, gi1, gc, gi2, gi3);
61 dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_RECEIVED);
62 publish(NULL, ERR_NONE, dataUpdated);
64 } else if (subType == NOTI_SEND_FINISH) {
65 _D("sub type: %d, gi1: %d, gc: %s, gi2: %d, gi3: %d", subType, gi1, gc, gi2, gi3);
67 dataUpdated.set(NULL, SOCIAL_ST_EVENT, SOCIAL_ST_SENT);
68 publish(NULL, ERR_NONE, dataUpdated);
73 int SocialStatusEmail::subscribe()
75 __dbusSignalId = __dbusWatcher.watch(NULL, NULL, "User.Email.NetworkStatus", "email", this);
76 IF_FAIL_RETURN_TAG(__dbusSignalId >= 0, ERR_OPERATION_FAILED, _E, "Email dbus signal subscription failed");
81 int SocialStatusEmail::unsubscribe()
83 __dbusWatcher.unwatch(__dbusSignalId);