comparison libpurple/protocols/myspace/myspace.c @ 19433:9a1b28a10c95

In msimprpl, move session-related functions to a new session module.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 26 Aug 2007 06:36:56 +0000
parents 210f792efd7c
children 1e00b684c46f
comparison
equal deleted inserted replaced
19432:210f792efd7c 19433:9a1b28a10c95
3359 session->fd = source; 3359 session->fd = source;
3360 3360
3361 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); 3361 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc);
3362 } 3362 }
3363 3363
3364 /* Session methods */ 3364
3365
3366 /**
3367 * Create a new MSIM session.
3368 *
3369 * @param acct The account to create the session from.
3370 *
3371 * @return Pointer to a new session. Free with msim_session_destroy.
3372 */
3373 MsimSession *
3374 msim_session_new(PurpleAccount *acct)
3375 {
3376 MsimSession *session;
3377
3378 g_return_val_if_fail(acct != NULL, NULL);
3379
3380 session = g_new0(MsimSession, 1);
3381
3382 session->magic = MSIM_SESSION_STRUCT_MAGIC;
3383 session->account = acct;
3384 session->gc = purple_account_get_connection(acct);
3385 session->sesskey = 0;
3386 session->userid = 0;
3387 session->username = NULL;
3388 session->fd = -1;
3389
3390 /* TODO: Remove. */
3391 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash,
3392 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */
3393 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash,
3394 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are,
3395 they could be integers inside gpointers
3396 or strings, so I don't freed them.
3397 Figure this out, once free cache. */
3398
3399 /* Created in msim_process_server_info() */
3400 session->server_info = NULL;
3401
3402 session->rxoff = 0;
3403 session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE);
3404 session->next_rid = 1;
3405 session->last_comm = time(NULL);
3406 session->inbox_status = 0;
3407
3408 return session;
3409 }
3410
3411 /**
3412 * Free a session.
3413 *
3414 * @param session The session to destroy.
3415 */
3416 void
3417 msim_session_destroy(MsimSession *session)
3418 {
3419 g_return_if_fail(MSIM_SESSION_VALID(session));
3420
3421 session->magic = -1;
3422
3423 g_free(session->rxbuf);
3424 g_free(session->username);
3425
3426 /* TODO: Remove. */
3427 g_hash_table_destroy(session->user_lookup_cb);
3428 g_hash_table_destroy(session->user_lookup_cb_data);
3429
3430 if (session->server_info) {
3431 msim_msg_free(session->server_info);
3432 }
3433
3434 g_free(session);
3435 }
3436
3437 /** 3365 /**
3438 * Close the connection. 3366 * Close the connection.
3439 * 3367 *
3440 * @param gc The connection. 3368 * @param gc The connection.
3441 */ 3369 */