示例#1
0
int
main (int argc, char **argv)
{
        GMainLoop        *main_loop;
        LmConnection     *connection;
        LmMessageHandler *handler;
        gboolean          result;
        UserInfo         *info;
	LmProxy          *proxy; 
	guint             proxy_port;
                                                                                
        if (argc < 6) {
                g_print ("Usage: %s <server> <username> <password> <proxyserver> <proxyport>\n", argv[0]);
                return 1;
        }
                                                                                
        connection = lm_connection_new (argv[1]);

	proxy = lm_proxy_new (LM_PROXY_TYPE_HTTP);
	lm_proxy_set_server (proxy, argv[4]);

	proxy_port = strtol (argv[5], (char **) NULL, 10);
	lm_proxy_set_port (proxy, proxy_port);
	lm_connection_set_proxy (connection, proxy);
	lm_proxy_unref (proxy);
                                                                                
        handler = lm_message_handler_new (handle_messages, NULL, NULL);
        lm_connection_register_message_handler (connection, handler,
                                                LM_MESSAGE_TYPE_MESSAGE,
                                                LM_HANDLER_PRIORITY_NORMAL);
                                                                                
        lm_message_handler_unref (handler);
                                                                                
        info = g_new0 (UserInfo, 1);
        info->name = g_strdup (argv[2]);
        info->passwd = g_strdup (argv[3]);
                                                                                
        result = lm_connection_open (connection,
                                     (LmResultFunction) connection_open_cb,
                                     info, NULL, NULL);
                                                                                
        if (!result) {
                g_print ("Opening connection failed: %d\n", result);
        } else {
                g_print ("Returned from the connection_open\n");
        }
                                                                                
        main_loop = g_main_loop_new (NULL, FALSE);
        g_main_loop_run (main_loop);
                                                                                
        return 0;
}
示例#2
0
/**
 * lm_proxy_new_with_server
 * @type: the type of the new proxy
 * @server: the proxy server
 * @port: the proxy server port
 *
 * Creates a new Proxy. Use #lm_connection_set_proxy to make a connection
 * user this proxy.
 *
 * Return value: a newly create proxy
 **/
LmProxy *
lm_proxy_new_with_server (LmProxyType  type,
                          const gchar *server,
                          guint        port)
{
    LmProxy *proxy;

    proxy = lm_proxy_new (type);
    lm_proxy_set_server (proxy, server);
    lm_proxy_set_port (proxy, port);

    return proxy;
}