* limitations under the License.
*/
-#include <gio/gio.h>
#include <systemd/sd-login.h>
#include "MsgDebug.h"
#include "MsgGconfWrapper.h"
#include "MsgUtilFile.h"
#include "MsgUtilFunction.h"
+#include "MsgUtilStorage.h"
#include <system_info.h>
#include <libintl.h>
#include <ctype.h>
#include <aul.h>
#include <aul_svc.h>
+#include <gio/gio.h>
typedef struct _msg_launch_app_data {
char *app_id;
#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 = 1,
[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
==================================================================================================*/
}
+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;
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* _msg_launch_app(void *data)
{
+ 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_DEBUG("aul_launch_app_for_uid() is failed : %d", ret);
+ MSG_ERR("aul_launch_app_for_uid() is failed : %d", ret);
}
g_free(ad->app_id);
bundle_free(ad->bundle_data);
g_free(ad);
}
+ pthread_mutex_unlock(&mx);
return NULL;
}
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_DEBUG("pthread_create() error");
+ MSG_ERR("pthread_create() error");
}
pthread_detach(thd);
{
int ret = aul_svc_set_operation(bundle_data, operation);
if (ret < 0) {
- MSG_DEBUG("aul_svc_set_operation() is failed : %d", ret);
+ MSG_ERR("aul_svc_set_operation() is failed : %d", ret);
return MSG_ERR_UNKNOWN;
}
{
int ret = aul_svc_set_uri(bundle_data, uri);
if (ret < 0) {
- MSG_DEBUG("aul_svc_set_uri() is failed : %d", ret);
+ MSG_ERR("aul_svc_set_uri() is failed : %d", ret);
return MSG_ERR_UNKNOWN;
}
}
-void MsgDbusInit()
+void msg_set_dpm_policy(int type, int state)
{
- MSG_DEBUG();
-
- _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);
+ dpm_policy_enable[type] = state;
+}
- if (_dbus_owner_id == 0) {
- MSG_ERR("g_bus_own_name() error");
- }
- MSG_DEBUG("owner_id = [%d]", _dbus_owner_id);
+bool msg_check_dpm_policy(int type)
+{
+ return dpm_policy_enable[MSG_SMS_TYPE];
+// return dpm_policy_enable[type];
}
-void MsgDbusDeinit()
+
+void msg_syspopup_message(bool is_sending)
{
- MSG_DEBUG();
- if (_dbus_owner_id)
- g_bus_unown_name(_dbus_owner_id);
+ 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;
+ }
- _dbus_owner_id = 0;
+ if (dbus_proxy) {
+ g_object_unref(dbus_proxy);
+ dbus_proxy = NULL;
+ }
+
+ if (result) {
+ g_object_unref(result);
+ result = NULL;
+ }
}