* limitations under the License.
*/
-#include <gio/gio.h>
#include <systemd/sd-login.h>
#include "MsgDebug.h"
#include "MsgContact.h"
+#include "MsgGconfWrapper.h"
#include "MsgUtilFile.h"
#include "MsgUtilFunction.h"
+#include "MsgUtilStorage.h"
#include <system_info.h>
#include <libintl.h>
#include <locale.h>
#include <vconf.h>
#include <ctype.h>
+#include <aul.h>
+#include <aul_svc.h>
+#include <gio/gio.h>
+
+typedef struct _msg_launch_app_data {
+ char *app_id;
+ bundle *bundle_data;
+} msg_launch_app_data;
+#define DEFAULT_MIN_MATCH_DIGIT 8
+
+#define SYSPOPUP_BUS_NAME "org.tizen.DevicePolicyManager"
+#define SYSPOPUP_OBJECT_PATH "/org/tizen/DevicePolicyManager/Syspopup"
+#define SYSPOPUP_INTERFACE "org.tizen.DevicePolicyManager.Syspopup"
+#define SYSPOPUP_METHOD_SHOW "show"
enum _FEATURE_INDEX_E {
FEATURE_INDEX_SMS = 0,
[FEATURE_INDEX_MMS] = false,
};
-int _dbus_owner_id = 0;
+static int dpm_policy_enable[] = {
+ [MSG_UNKNOWN_TYPE] = 0,
+ [MSG_SMS_TYPE] = 1,
+ [MSG_MMS_TYPE] = 1,
+};
+
+#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+static int phonenumberMinMatchDigit = -1;
+#endif
+
+pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER;
/*==================================================================================================
FUNCTION IMPLEMENTATION
return result;
}
+
+int MsgContactGetMinMatchDigit()
+{
+#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+ if (phonenumberMinMatchDigit <= 0) {
+ if (MsgSettingGetInt(VCONFKEY_CONTACTS_SVC_PHONENUMBER_MIN_MATCH_DIGIT, &phonenumberMinMatchDigit) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ MSG_DEBUG("phonenumberMinMatchDigit [%d]", phonenumberMinMatchDigit);
+
+ if (phonenumberMinMatchDigit < 1) {
+ phonenumberMinMatchDigit = DEFAULT_MIN_MATCH_DIGIT;
+ }
+ }
+
+ return phonenumberMinMatchDigit;
+#else
+ return DEFAULT_MIN_MATCH_DIGIT;
+#endif
+}
+
/* Encoders */
int MsgEncodeCountInfo(MSG_COUNT_INFO_S *pCountInfo, char **ppDest)
{
}
+int MsgEncodeThreadChangeData(const msg_storage_change_type_t storageChangeType, const msg_thread_id_t threadId, char **ppDest)
+{
+ int dataSize = 0;
+
+ dataSize = sizeof(msg_storage_change_type_t) + sizeof(msg_thread_id_t);
+
+ *ppDest = (char*)new char[dataSize];
+
+ void* p = (void*)*ppDest;
+
+ memcpy(p, &storageChangeType, sizeof(msg_storage_change_type_t));
+ p = (void*)((char*)p + sizeof(msg_storage_change_type_t));
+
+ memcpy(p, &threadId, sizeof(msg_thread_id_t));
+
+ return dataSize;
+}
+
+
int MsgEncodeReportMsgData(const msg_report_type_t msgReportType, const MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest)
{
int dataSize = 0;
else
strncpy(order, "DESC", 5);
- int nameOrder = MsgGetContactNameOrder();
-
switch (pSortRule->sortType) {
case MSG_SORT_BY_DISPLAY_FROM :
- if (nameOrder == 0)
- snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
- else
- snprintf(sql, sizeof(sql), "ORDER BY B.LAST_NAME %s, B.FIRST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
+ snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
break;
case MSG_SORT_BY_DISPLAY_TO :
- if (nameOrder == 0)
- snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
- else
- snprintf(sql, sizeof(sql), "ORDER BY B.LAST_NAME %s, B.FIRST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
+ snprintf(sql, sizeof(sql), "ORDER BY B.FIRST_NAME %s, B.LAST_NAME %s, B.ADDRESS_VAL, A.DISPLAY_TIME DESC;", order, order);
break;
case MSG_SORT_BY_DISPLAY_TIME :
snprintf(sql, sizeof(sql), "ORDER BY DISPLAY_TIME %s;", order);
snprintf(sql, sizeof(sql), "ORDER BY A.STORAGE_ID %s, A.DISPLAY_TIME DESC;", order);
break;
case MSG_SORT_BY_THREAD_NAME :
- if (nameOrder == 0)
- snprintf(sql, sizeof(sql), "ORDER BY FIRST_NAME %s, LAST_NAME %s;", order, order);
- else
- snprintf(sql, sizeof(sql), "ORDER BY LAST_NAME %s, FIRST_NAME %s;", order, order);
+ snprintf(sql, sizeof(sql), "ORDER BY FIRST_NAME %s, LAST_NAME %s;", order, order);
break;
case MSG_SORT_BY_THREAD_DATE :
snprintf(sql, sizeof(sql), "ORDER BY MSG_TIME %s;", order);
static int __find_login_user(uid_t *uid)
{
uid_t *uids = NULL;
- char *state = NULL;
- int uids_len = sd_get_uids(&uids);
- if (uids_len <= 0)
+ int uids_len = sd_get_active_uids(&uids);
+ if (uids == NULL)
return -1;
- for (int i = 0; i < uids_len; i++) {
- if (sd_uid_get_state(uids[i], &state) < 0) {
- free(uids);
- return -1;
- } else {
- if (g_strcmp0(state, "online") == 0) {
- *uid = uids[i];
- free(uids);
- free(state);
- return 0;
- }
- }
-
- free(state);
+ if (uids_len != 1) {
+ free(uids);
+ return -1;
}
+ *uid = uids[0];
+
free(uids);
- return -1;
+ return 0;
}
}
-void MsgDbusInit()
+void* _msg_launch_app(void *data)
{
- MSG_DEBUG();
+ pthread_mutex_lock(&mx);
+ if (data) {
+ msg_launch_app_data *ad = (msg_launch_app_data *)data;
+ int ret = aul_launch_app_for_uid(ad->app_id, ad->bundle_data, msg_get_login_user());
+ if (ret <= 0) {
+ MSG_ERR("aul_launch_app_for_uid() is failed : %d", ret);
+ }
- _dbus_owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- "msg-service.dbus.service",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL,
- NULL, NULL);
+ g_free(ad->app_id);
+ bundle_free(ad->bundle_data);
+ g_free(ad);
+ }
+ pthread_mutex_unlock(&mx);
+
+ return NULL;
+}
- if (_dbus_owner_id == 0) {
- MSG_ERR("g_bus_own_name() error");
+msg_error_t msg_launch_app(const char *app_id, bundle *bundle_data)
+{
+ msg_launch_app_data *data = (msg_launch_app_data *)calloc(1, sizeof(msg_launch_app_data));
+ if (data == NULL) {
+ MSG_ERR("Memory alloc failed!");
+ return MSG_ERR_MEMORY_ERROR;
+ }
+
+ data->app_id = g_strdup(app_id);
+ data->bundle_data = bundle_dup(bundle_data);
+ pthread_t thd;
+
+ if (pthread_create(&thd, NULL, &_msg_launch_app, data) < 0) {
+ MSG_ERR("pthread_create() error");
+ }
+
+ pthread_detach(thd);
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t msg_aul_svc_set_operation(bundle *bundle_data, const char *operation)
+{
+ int ret = aul_svc_set_operation(bundle_data, operation);
+ if (ret < 0) {
+ MSG_ERR("aul_svc_set_operation() is failed : %d", ret);
+ return MSG_ERR_UNKNOWN;
}
- MSG_DEBUG("owner_id = [%d]", _dbus_owner_id);
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t msg_aul_svc_set_uri(bundle *bundle_data, char *uri)
+{
+ int ret = aul_svc_set_uri(bundle_data, uri);
+ if (ret < 0) {
+ MSG_ERR("aul_svc_set_uri() is failed : %d", ret);
+ return MSG_ERR_UNKNOWN;
+ }
+
+ return MSG_SUCCESS;
+}
+
+
+void msg_set_dpm_policy(int type, int state)
+{
+ dpm_policy_enable[type] = state;
}
-void MsgDbusDeinit()
+
+bool msg_check_dpm_policy(int type)
{
- MSG_DEBUG();
- if (_dbus_owner_id)
- g_bus_unown_name(_dbus_owner_id);
+ return dpm_policy_enable[MSG_SMS_TYPE];
+// return dpm_policy_enable[type];
+}
+
- _dbus_owner_id = 0;
+void msg_syspopup_message(bool is_sending)
+{
+ MSG_INFO("popup toast for dpm restriction. is_sending [%d]", is_sending);
+
+ GDBusConnection *connection = NULL;
+ GDBusProxy *dbus_proxy = NULL;
+ GVariant *result = NULL;
+ GError *error = NULL;
+
+ connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ MSG_ERR("Connecting to system bus failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ dbus_proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ SYSPOPUP_BUS_NAME, SYSPOPUP_OBJECT_PATH, SYSPOPUP_INTERFACE, NULL, &error);
+ if (error) {
+ MSG_ERR("Connecting to proxy failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ result = g_dbus_proxy_call_sync(dbus_proxy, SYSPOPUP_METHOD_SHOW,
+ g_variant_new("(s)", is_sending ? "message-sending" : "message-retrieving"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ MSG_ERR("invoking proxy call failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+_DBUS_ERROR:
+ if (error) {
+ g_error_free(error);
+ error = NULL;
+ }
+
+ if (connection) {
+ g_object_unref(connection);
+ connection = NULL;
+ }
+
+ if (dbus_proxy) {
+ g_object_unref(dbus_proxy);
+ dbus_proxy = NULL;
+ }
+
+ if (result) {
+ g_object_unref(result);
+ result = NULL;
+ }
}