mark PurpleImageClass as private
[pidgin-git.git] / libpurple / protocols / novell / nmmessage.c
blob3bc69d5076de882af9944e3cdabb7ac047424ee3
1 /*
2 * nmmessage.c
4 * Copyright (c) 2004 Novell, Inc. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 #include "nmmessage.h"
23 struct _NMMessage
25 NMConference *conference;
26 char *text;
27 guint32 ref_count;
31 /** Message API **/
33 NMMessage *
34 nm_create_message(const char *text)
36 NMMessage *msg = g_new0(NMMessage, 1);
38 if (text)
39 msg->text = g_strdup(text);
41 msg->ref_count = 1;
42 return msg;
45 void
46 nm_message_add_ref(NMMessage * msg)
48 if (msg)
49 msg->ref_count++;
52 void
53 nm_release_message(NMMessage * msg)
55 if (msg && (--(msg->ref_count) == 0)) {
56 g_free(msg->text);
58 if (msg->conference)
59 nm_release_conference(msg->conference);
61 g_free(msg);
65 const char *
66 nm_message_get_text(NMMessage * msg)
68 if (msg == NULL)
69 return NULL;
71 return msg->text;
74 void
75 nm_message_set_conference(NMMessage * msg, NMConference * conf)
77 if (msg == NULL || conf == NULL)
78 return;
80 /* Need to ref the conference first so that it doesn't
81 * get released out from under us
83 nm_conference_add_ref(conf);
85 msg->conference = conf;
88 NMConference *
89 nm_message_get_conference(NMMessage * msg)
91 if (msg == NULL)
92 return NULL;
94 return msg->conference;