comparison src/protocols/novell/nmmessage.c @ 8675:9ee2542d1104

[gaim-migrate @ 9428] A GroupWise plugin from Novell. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 17 Apr 2004 13:55:28 +0000
parents
children 046dd8ef2920
comparison
equal deleted inserted replaced
8674:8c7da2e36136 8675:9ee2542d1104
1 /*
2 * nmmessage.c
3 *
4 * Copyright © 2004 Unpublished Work of Novell, Inc. All Rights Reserved.
5 *
6 * THIS WORK IS AN UNPUBLISHED WORK OF NOVELL, INC. NO PART OF THIS WORK MAY BE
7 * USED, PRACTICED, PERFORMED, COPIED, DISTRIBUTED, REVISED, MODIFIED,
8 * TRANSLATED, ABRIDGED, CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED,
9 * RECAST, TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF NOVELL,
10 * INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT AUTHORIZATION COULD SUBJECT
11 * THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
12 *
13 * AS BETWEEN [GAIM] AND NOVELL, NOVELL GRANTS [GAIM] THE RIGHT TO REPUBLISH
14 * THIS WORK UNDER THE GPL (GNU GENERAL PUBLIC LICENSE) WITH ALL RIGHTS AND
15 * LICENSES THEREUNDER. IF YOU HAVE RECEIVED THIS WORK DIRECTLY OR INDIRECTLY
16 * FROM [GAIM] AS PART OF SUCH A REPUBLICATION, YOU HAVE ALL RIGHTS AND LICENSES
17 * GRANTED BY [GAIM] UNDER THE GPL. IN CONNECTION WITH SUCH A REPUBLICATION, IF
18 * ANYTHING IN THIS NOTICE CONFLICTS WITH THE TERMS OF THE GPL, SUCH TERMS
19 * PREVAIL.
20 *
21 */
22
23 #include "nmmessage.h"
24
25 struct _NMMessage
26 {
27 NMConference *conference;
28 char *text;
29 gpointer data;
30 guint32 ref_count;
31 };
32
33
34 /** Message API **/
35
36 NMMessage *
37 nm_create_message(const char *text)
38 {
39 NMMessage *msg = g_new0(NMMessage, 1);
40
41 if (text)
42 msg->text = g_strdup(text);
43
44 msg->ref_count = 1;
45 return msg;
46 }
47
48 void
49 nm_release_message(NMMessage * msg)
50 {
51 if (msg && (--(msg->ref_count) == 0)) {
52 if (msg->text)
53 g_free(msg->text);
54
55 if (msg->conference)
56 nm_release_conference(msg->conference);
57
58 g_free(msg);
59 }
60 }
61
62 const char *
63 nm_message_get_text(NMMessage * msg)
64 {
65 if (msg == NULL)
66 return NULL;
67
68 return msg->text;
69 }
70
71 void
72 nm_message_set_conference(NMMessage * msg, NMConference * conf)
73 {
74 if (msg == NULL || conf == NULL)
75 return;
76
77 /* Need to ref the conference first so that it doesn't
78 * get released out from under us
79 */
80 nm_conference_add_ref(conf);
81
82 msg->conference = conf;
83 }
84
85 NMConference *
86 nm_message_get_conference(NMMessage * msg)
87 {
88 if (msg == NULL)
89 return NULL;
90
91 return msg->conference;
92 }