static gboolean proxy_read_cb (GIOChannel *source, GIOCondition condition, gpointer data) { LmConnectData *connect_data; LmConnection *connection; LmProxy *proxy; gboolean retval = FALSE; connect_data = (LmConnectData *) data; connection = connect_data->connection; proxy = lm_connection_get_proxy (connection); g_return_val_if_fail (proxy != NULL, FALSE); if (lm_connection_is_open (connection)) { return FALSE; } switch (lm_proxy_get_type (proxy)) { default: case LM_PROXY_TYPE_NONE: g_assert_not_reached (); break; case LM_PROXY_TYPE_HTTP: retval = proxy_http_read_cb (source, condition, data); break; } if (retval == TRUE) { g_source_remove (proxy->io_watch); _lm_old_socket_succeeded ((LmConnectData *) data); } return FALSE; }
void xmpp_connect() { GError *err = NULL; const gchar *conf_server; LmSSL *ssl; int use_ssl, use_tls, port; const gchar *jid; wantconnection = 1; if (connection && lm_connection_is_open(connection)) { ui_print("connect: connection alredy opened, aborting\n"); return; } if (connection == NULL) connection = lm_connection_new(NULL); use_ssl = get_settings_int(USE_SSL); use_tls = get_settings_int(USE_TLS); jid = get_settings_str(JID); port = get_settings_int(PORT); if (use_ssl || use_tls) { if (!lm_ssl_is_supported()) { ui_print("Error: SSL not available\n"); } else if (use_ssl && use_tls) { ui_print("Error: You can't use ssl and tls at the same time"); } else { ssl = lm_ssl_new(NULL, ssl_cb, NULL, NULL); lm_ssl_use_starttls(ssl, !use_ssl, use_tls); lm_connection_set_ssl(connection, ssl); lm_ssl_unref(ssl); } } if (!port) { port = (use_ssl) ? LM_CONNECTION_DEFAULT_PORT_SSL : LM_CONNECTION_DEFAULT_PORT; } lm_connection_set_port(connection, port); lm_connection_set_jid(connection, jid); lm_connection_set_keep_alive_rate(connection, 30); lm_connection_set_disconnect_function(connection, connection_disconnect_cb, NULL, NULL); conf_server = get_settings_str(SERVER); if (!conf_server) { ui_print("ERROR: Insufficient configuration, " "connecting aborted (server not set)\n"); return; } else { if(!lm_connection_get_server(connection)) lm_connection_set_server(connection, conf_server); } ui_print("Opening connection to %s\n", conf_server); if(!lm_connection_open(connection, (LmResultFunction)connection_open_cb, NULL, NULL, &err)) { ui_print("Error opening connection: %s\n", err->message); g_error_free(err); } } /* xmpp_connect */
LM::Account::~Account () { if (lm_connection_is_open (connection)) { handle_down (); lm_connection_close (connection, NULL); } lm_connection_unref (connection); connection = 0; }
gboolean close_connection(MP3tunesHarmony *harmony) { GError *err = NULL; if (lm_connection_is_open(harmony->connection)) { lm_connection_close(harmony->connection, &err); lm_connection_unref(harmony->connection); if (err != NULL) { error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Closing the connection failed", err); return FALSE; } /* return TRUE; */ /* state_change_emit(harmony, MP3TUNES_HARMONY_STATE_DISCONNECTED); */ } return TRUE; }
gboolean open_connection(MP3tunesHarmony *harmony) { GError *err = NULL; rebuild_connection(harmony); if (!lm_connection_is_open(harmony->connection)) { lm_connection_open(harmony->connection, (LmResultFunction) open_connection_callback, harmony, NULL, &err); if (err != NULL) { error_emit(harmony, MP3TUNES_HARMONY_ERROR_MISC, "Opening the connection failed", err); return FALSE; } } return TRUE; }
void xmpp_disconnect() { LmMessage *m; const gchar *conf_server = get_settings_str(SERVER); wantconnection = 0; if (connection == NULL) return; if (lm_connection_get_state(connection) == LM_CONNECTION_STATE_AUTHENTICATED) { m = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_PRESENCE, LM_MESSAGE_SUB_TYPE_UNAVAILABLE); lm_connection_send(connection, m, NULL); } if(lm_connection_is_open(connection)) { ui_print("Closing connection to %s\n", conf_server); lm_connection_close(connection, NULL); g_printerr("Disconnected\n"); } lm_connection_unref(connection); connection = NULL; } /* xmpp_disconnect */
bool LM::Account::populate_menu (Ekiga::MenuBuilder& builder) { if (lm_connection_is_open (connection)) { builder.add_action ("user-offline", _("_Disable"), boost::bind (&LM::Account::disable, this)); } else { builder.add_action ("user-available", _("_Enable"), boost::bind (&LM::Account::enable, this)); } builder.add_separator (); builder.add_action ("gtk-edit", _("Edit"), boost::bind (&LM::Account::edit, this)); builder.add_action ("gtk-remove", _("_Remove"), boost::bind (&LM::Account::remove, this)); return true; }
int xmpp_connection_is_open(void) { return connection && lm_connection_is_open(connection); }
void jabber_change_status(GGaduStatusPrototype *sp, gboolean keep_desc) { enum states status; LmMessage *m = NULL; gchar *show = NULL; gchar *show_away = "away"; gchar *show_xa = "xa"; gchar *show_dnd = "dnd"; gchar *show_chat = "chat"; print_debug("jabber_change_status start"); if (!sp) return; status = sp->status; /* Just a simple esthetic functionality */ if((jabber_data.status == JABBER_STATUS_UNAVAILABLE) && sp->status == JABBER_STATUS_UNAVAILABLE) { GGaduStatusPrototype *sp_temp = ggadu_find_status_prototype(p, jabber_data.status); sp_temp->status = JABBER_STATUS_UNAVAILABLE; if(sp_temp->status_description) { g_free(sp_temp->status_description); sp_temp->status_description = NULL; } signal_emit("jabber", "gui status changed", sp_temp, "main-gui"); GGaduStatusPrototype_free(sp_temp); return; } if (status == JABBER_STATUS_UNAVAILABLE) { lm_connection_close(jabber_data.connection, NULL); return; } /* connect if switched to any other than unavailable */ if ((jabber_data.status == JABBER_STATUS_UNAVAILABLE) && (status != JABBER_STATUS_UNAVAILABLE) && (!jabber_data.connection || !lm_connection_is_open(jabber_data.connection) || !lm_connection_is_authenticated(jabber_data.connection))) { g_thread_create(jabber_login_connect, (gpointer) status, FALSE, NULL); return; } if (jabber_data.connection && !lm_connection_is_authenticated(jabber_data.connection)) { print_debug("You are not yet authenticated!"); return; } m = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_PRESENCE, (status == JABBER_STATUS_UNAVAILABLE) ? LM_MESSAGE_SUB_TYPE_UNAVAILABLE : LM_MESSAGE_SUB_TYPE_AVAILABLE); /* switch (status == JABBER_STATUS_DESCR ? jabber_data.status : status) */ switch (status) { case JABBER_STATUS_AWAY: show = show_away; break; case JABBER_STATUS_XA: show = show_xa; break; case JABBER_STATUS_DND: show = show_dnd; break; case JABBER_STATUS_CHAT: show = show_chat; break; case JABBER_STATUS_AVAILABLE: show = NULL; break; default: break; } if (show) lm_message_node_add_child(m->node, "show", show); if(keep_desc) { if(sp->status_description) g_free(sp->status_description); sp->status_description = g_strdup(jabber_data.description); } if(jabber_data.description) { g_free(jabber_data.description); jabber_data.description = NULL; } if (sp->status_description) { print_debug("jabber: status description %s %s",sp->status_description,show); lm_message_node_add_child(m->node, "status", sp->status_description); jabber_data.description = g_strdup(sp->status_description); } print_debug(lm_message_node_to_string(m->node)); if (!lm_connection_send(jabber_data.connection, m, NULL)) { print_debug("jabber: Couldn't change status!\n"); } else { jabber_data.status = status; signal_emit("jabber", "gui status changed", sp, "main-gui"); } lm_message_unref(m); print_debug("jabber_change_status end"); }