annotate src/protocols/msn/state.c @ 9863:0e3a84f18467

[gaim-migrate @ 10742] Whitespace and comment changes, mostly. And changed a few other things that aren't ansi c... committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 25 Aug 2004 03:09:08 +0000
parents 572e4658492c
children bcfea6c3d5c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5361
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file state.c State functions and definitions
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
8 * source distribution.
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5824
diff changeset
9 *
5361
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * (at your option) any later version.
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 *
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * GNU General Public License for more details.
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 *
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 */
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "msn.h"
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "state.h"
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 static const char *away_text[] =
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 {
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 N_("Available"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 N_("Available"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 N_("Busy"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 N_("Idle"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 N_("Be Right Back"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 N_("Away From Computer"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 N_("On The Phone"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 N_("Out To Lunch"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 N_("Available"),
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 N_("Available")
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 };
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
41 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
42 msn_change_status(MsnSession *session, MsnAwayType state)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
43 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
44 MsnCmdProc *cmdproc;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
45 MsnUser *user;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
46 MsnObject *msnobj;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
47 const char *state_text;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
48
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
49 cmdproc = session->notification->cmdproc;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
50 user = session->user;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
51 state_text = msn_state_get_text(state);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
52
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
53 g_return_if_fail(session != NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
54
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
55 msnobj = msn_user_get_object(user);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
56
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
57 if (msnobj == NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
58 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
59 msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
60 MSN_CLIENT_ID);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
61 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
62 else
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
63 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
64 char *msnobj_str;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
65
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
66 msnobj_str = msn_object_to_string(msnobj);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
67
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
68 msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state_text,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
69 MSN_CLIENT_ID, gaim_url_encode(msnobj_str));
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
70
9262
572e4658492c [gaim-migrate @ 10061]
Christian Hammond <chipx86@chipx86.com>
parents: 9198
diff changeset
71 /*
572e4658492c [gaim-migrate @ 10061]
Christian Hammond <chipx86@chipx86.com>
parents: 9198
diff changeset
72 * We need to set this just in case someone tries to set icon
572e4658492c [gaim-migrate @ 10061]
Christian Hammond <chipx86@chipx86.com>
parents: 9198
diff changeset
73 * quickly on us - Justin
572e4658492c [gaim-migrate @ 10061]
Christian Hammond <chipx86@chipx86.com>
parents: 9198
diff changeset
74 */
572e4658492c [gaim-migrate @ 10061]
Christian Hammond <chipx86@chipx86.com>
parents: 9198
diff changeset
75 session->state = state;
572e4658492c [gaim-migrate @ 10061]
Christian Hammond <chipx86@chipx86.com>
parents: 9198
diff changeset
76
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
77 g_free(msnobj_str);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
78 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
79 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
80
5361
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 const char *
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 msn_away_get_text(MsnAwayType type)
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 {
7631
ea2d07ad05a9 [gaim-migrate @ 8255]
Nathan Walp <nwalp@pidgin.im>
parents: 6701
diff changeset
84 g_return_val_if_fail(type <= MSN_HIDDEN, NULL);
5361
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
5824
c93884a14866 [gaim-migrate @ 6254]
Luke Schierer <lschiere@pidgin.im>
parents: 5361
diff changeset
86 return _(away_text[type]);
5361
953aa05279f4 [gaim-migrate @ 5737]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
88
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
89 const char *
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
90 msn_state_get_text(MsnAwayType state)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
91 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
92 static char *status_text[] =
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
93 { "NLN", "NLN", "BSY", "IDL", "BRB", "AWY", "PHN", "LUN", "HDN", "HDN" };
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
94
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
95 return status_text[state];
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
96 }