~ctrlproxy/ctrlproxy/trunk

« back to all changes in this revision

Viewing changes to src/client.c

  • Committer: Jelmer Vernooij
  • Date: 2008-09-28 20:42:03 UTC
  • Revision ID: jelmer@samba.org-20080928204203-1xt9pry0gig9w1ox
Add abstraction for connecting to network.

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
                c->network->clients = g_list_remove(c->network->clients, c);
218
218
}
219
219
 
 
220
static struct irc_network *client_connect_command(struct irc_client *client, const char *hostname, guint16 port)
 
221
{
 
222
        extern struct global *my_global;
 
223
 
 
224
        struct irc_network *network;
 
225
 
 
226
        network = network_ref(find_network_by_hostname(my_global, 
 
227
                                                                                                   hostname, port, my_global->config->create_implicit, 
 
228
                                                                                                   client->login_details));
 
229
 
 
230
        if (network == NULL) {
 
231
                client_log(LOG_ERROR, client, 
 
232
                        "Unable to connect to network with name %s", 
 
233
                        hostname);
 
234
                return NULL;
 
235
        }
 
236
 
 
237
        if (network->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
 
238
                client_send_args(client, "NOTICE", 
 
239
                                                        client_get_default_target(client),
 
240
                                                        "Connecting to network", NULL);
 
241
                connect_network(network);
 
242
        }
 
243
 
 
244
        return network;
 
245
}
 
246
 
220
247
void log_client(enum log_level, const struct irc_client *, const char *data);
221
248
static struct irc_client_callbacks default_callbacks = {
222
249
        .process_from_client = process_from_client, 
225
252
        .disconnect = handle_client_disconnect,
226
253
        .free_private_data = client_free_private,
227
254
        .welcome = welcome_client,
 
255
        .on_connect = client_connect_command,
228
256
};
229
257
 
230
258
struct irc_client *client_init_iochannel(struct irc_network *n, GIOChannel *c, const char *desc)