Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- e_ews_connection_new (const gchar *uri, const gchar *username, const gchar *password,
- GCallback authenticate_cb, gpointer authenticate_ctx,
- GError **error)
- {
- EEwsConnection *cnc;
- gchar *hash_key;
- g_static_mutex_lock (&connecting);
- /* search the connection in our hash table */
- if (loaded_connections_permissions != NULL) {
- hash_key = g_strdup_printf ("%s@%s",
- username ? username : "",
- uri);
- cnc = g_hash_table_lookup (loaded_connections_permissions, hash_key);
- g_free (hash_key);
- if (E_IS_EWS_CONNECTION (cnc)) {
- g_object_ref (cnc);
- g_static_mutex_unlock (&connecting);
- return cnc;
- }
- }
- /* not found, so create a new connection */
- cnc = g_object_new (E_TYPE_EWS_CONNECTION, NULL);
- cnc->priv->username = g_strdup (username);
- cnc->priv->password = g_strdup (password);
- cnc->priv->uri = g_strdup (uri);
- /* register a handler to the authenticate signal */
- if (authenticate_cb)
- g_signal_connect (cnc, "authenticate",
- authenticate_cb, authenticate_ctx);
- /* add the connection to the loaded_connections_permissions hash table */
- hash_key = g_strdup_printf ("%s@%s",
- cnc->priv->username ? cnc->priv->username : "",
- cnc->priv->uri);
- if (loaded_connections_permissions == NULL)
- loaded_connections_permissions = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- g_hash_table_insert (loaded_connections_permissions, hash_key, cnc);
- /* free memory */
- g_static_mutex_unlock (&connecting);
- return cnc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement