Commit 0b968bcf authored by Srinivasa Ragavan's avatar Srinivasa Ragavan

Add API to get folder from URI.

parent f9fffea9
......@@ -267,6 +267,72 @@ impl_Mail_getLocalFolder (EGdbusSessionCS *object, GDBusMethodInvocation *invoca
return TRUE;
}
static void
get_folder_done (gchar *uri, CamelFolder *folder, gpointer d, GError *error)
{
EMailGetStoreData *data = (EMailGetStoreData *)d;
EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(data->msession);
CamelStore *store;
char *fpath, *spath;
char *url;
EMailDataStore *estore;
const gchar *sender;
GList *list;
if (folder == NULL) {
ipc(printf("Unable to get folder: %s\n", error->message));
g_dbus_method_invocation_return_gerror (data->invocation, error);
}
store = camel_folder_get_parent_store (folder);
g_mutex_lock (priv->datastores_lock);
estore = g_hash_table_lookup (priv->datastores, store);
if (estore == NULL) {
url = camel_url_to_string(((CamelService *)store)->url, CAMEL_URL_HIDE_ALL);
spath = construct_mail_session_path ();
estore = e_mail_data_store_new (store, url);
g_hash_table_insert (priv->datastores, store, estore);
e_mail_data_store_register_gdbus_object (estore, g_dbus_method_invocation_get_connection (data->invocation), spath, NULL);
g_free (url);
g_free (spath);
}
g_mutex_unlock (priv->datastores_lock);
g_mutex_lock (priv->connections_lock);
sender = g_dbus_method_invocation_get_sender (data->invocation);
list = g_hash_table_lookup (priv->connections, sender);
list = g_list_prepend (list, estore);
g_hash_table_insert (priv->connections, g_strdup (sender), list);
g_mutex_unlock (priv->connections_lock);
fpath = e_mail_data_store_get_folder_path (estore, g_dbus_method_invocation_get_connection (data->invocation), folder);
egdbus_session_cs_complete_get_folder_from_uri (data->object, data->invocation, fpath);
ipc (printf("EMailDataSession: Get Folder from URI : Success %s for sender: '%s'\n", fpath, sender));
g_free (data);
}
static gboolean
impl_Mail_getFolderFromUri (EGdbusSessionCS *object, GDBusMethodInvocation *invocation, const char *uri, EMailDataSession *msession)
{
EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
EMailGetStoreData *data = g_new0(EMailGetStoreData, 1);
data->invocation = invocation;
data->msession = msession;
data->object = object;
mail_get_folder (uri, 0, get_folder_done, data, mail_msg_unordered_push);
return TRUE;
}
static void
e_mail_data_session_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
......@@ -323,6 +389,7 @@ e_mail_data_session_init (EMailDataSession *self)
g_signal_connect (priv->gdbus_object, "handle-get-store", G_CALLBACK (impl_Mail_getStore), self);
g_signal_connect (priv->gdbus_object, "handle-get-local-store", G_CALLBACK (impl_Mail_getLocalStore), self);
g_signal_connect (priv->gdbus_object, "handle-get-local-folder", G_CALLBACK (impl_Mail_getLocalFolder), self);
g_signal_connect (priv->gdbus_object, "handle-get-folder-from-uri", G_CALLBACK (impl_Mail_getFolderFromUri), self);
priv->stores_lock = g_mutex_new ();
priv->stores = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
......
......@@ -28,6 +28,11 @@
<arg name="type" type="s" direction="in"/>
<arg name="folder" type="o" direction="out"/>
</method>
<method name="getFolderFromUri">
<arg name="uri" type="s" direction="in"/>
<arg name="folder" type="o" direction="out"/>
</method>
<signal name="GetPassword">
<arg name="title" type="s"/>
<arg name="prompt" type="s"/>
......
......@@ -451,11 +451,58 @@ static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_get_local_f
"handle-get-local-folder"
};
static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_get_folder_from_uri_IN_ARG_uri =
{
{
-1,
"uri",
"s",
NULL
},
FALSE
};
static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_get_folder_from_uri_IN_ARG_pointers[] =
{
&_egdbus_session_cs_method_info_get_folder_from_uri_IN_ARG_uri,
NULL
};
static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_get_folder_from_uri_OUT_ARG_folder =
{
{
-1,
"folder",
"o",
NULL
},
FALSE
};
static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_get_folder_from_uri_OUT_ARG_pointers[] =
{
&_egdbus_session_cs_method_info_get_folder_from_uri_OUT_ARG_folder,
NULL
};
static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_get_folder_from_uri =
{
{
-1,
"getFolderFromUri",
(GDBusArgInfo **) &_egdbus_session_cs_method_info_get_folder_from_uri_IN_ARG_pointers,
(GDBusArgInfo **) &_egdbus_session_cs_method_info_get_folder_from_uri_OUT_ARG_pointers,
NULL
},
"handle-get-folder-from-uri"
};
static const _ExtendedGDBusMethodInfo * const _egdbus_session_cs_method_info_pointers[] =
{
&_egdbus_session_cs_method_info_get_store,
&_egdbus_session_cs_method_info_get_local_store,
&_egdbus_session_cs_method_info_get_local_folder,
&_egdbus_session_cs_method_info_get_folder_from_uri,
NULL
};
......@@ -587,6 +634,17 @@ egdbus_session_cs_default_init (EGdbusSessionCSIface *iface)
2,
G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
g_signal_new ("handle-get-folder-from-uri",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EGdbusSessionCSIface, handle_get_folder_from_uri),
g_signal_accumulator_true_handled,
NULL,
_cclosure_marshal_generic,
G_TYPE_BOOLEAN,
2,
G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
/* GObject signals for received D-Bus signals: */
g_signal_new ("get-password",
G_TYPE_FROM_INTERFACE (iface),
......@@ -806,6 +864,71 @@ _out:
return _ret != NULL;
}
void
egdbus_session_cs_call_get_folder_from_uri (
EGdbusSessionCS *proxy,
const gchar *uri,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_dbus_proxy_call (G_DBUS_PROXY (proxy),
"getFolderFromUri",
g_variant_new ("(s)",
uri),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
callback,
user_data);
}
gboolean
egdbus_session_cs_call_get_folder_from_uri_finish (
EGdbusSessionCS *proxy,
gchar **out_folder,
GAsyncResult *res,
GError **error)
{
GVariant *_ret;
_ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
if (_ret == NULL)
goto _out;
g_variant_get (_ret,
"(o)",
out_folder);
g_variant_unref (_ret);
_out:
return _ret != NULL;
}
gboolean
egdbus_session_cs_call_get_folder_from_uri_sync (
EGdbusSessionCS *proxy,
const gchar *uri,
gchar **out_folder,
GCancellable *cancellable,
GError **error)
{
GVariant *_ret;
_ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
"getFolderFromUri",
g_variant_new ("(s)",
uri),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
error);
if (_ret == NULL)
goto _out;
g_variant_get (_ret,
"(o)",
out_folder);
g_variant_unref (_ret);
_out:
return _ret != NULL;
}
void
egdbus_session_cs_complete_get_store (
EGdbusSessionCS *object,
......@@ -839,6 +962,17 @@ egdbus_session_cs_complete_get_local_folder (
folder));
}
void
egdbus_session_cs_complete_get_folder_from_uri (
EGdbusSessionCS *object,
GDBusMethodInvocation *invocation,
const gchar *folder)
{
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)",
folder));
}
/* ------------------------------------------------------------------------ */
static void
......
......@@ -47,6 +47,11 @@ struct _EGdbusSessionCSIface
GDBusMethodInvocation *invocation,
const gchar *type);
gboolean (*handle_get_folder_from_uri) (
EGdbusSessionCS *object,
GDBusMethodInvocation *invocation,
const gchar *uri);
/* GObject signal class handlers for received D-Bus signals: */
void (*get_password) (
......@@ -78,6 +83,11 @@ void egdbus_session_cs_complete_get_local_folder (
GDBusMethodInvocation *invocation,
const gchar *folder);
void egdbus_session_cs_complete_get_folder_from_uri (
EGdbusSessionCS *object,
GDBusMethodInvocation *invocation,
const gchar *folder);
/* D-Bus signal emissions functions: */
......@@ -148,6 +158,26 @@ gboolean egdbus_session_cs_call_get_local_folder_sync (
GCancellable *cancellable,
GError **error);
void egdbus_session_cs_call_get_folder_from_uri (
EGdbusSessionCS *proxy,
const gchar *uri,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean egdbus_session_cs_call_get_folder_from_uri_finish (
EGdbusSessionCS *proxy,
gchar **out_folder,
GAsyncResult *res,
GError **error);
gboolean egdbus_session_cs_call_get_folder_from_uri_sync (
EGdbusSessionCS *proxy,
const gchar *uri,
gchar **out_folder,
GCancellable *cancellable,
GError **error);
/* ---- */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment