3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #include "purpleaccountusersplit.h"
24 /******************************************************************************
26 *****************************************************************************/
27 struct _PurpleAccountUserSplit
{
35 /******************************************************************************
37 *****************************************************************************/
39 PurpleAccountUserSplit
,
40 purple_account_user_split
,
41 purple_account_user_split_copy
,
42 purple_account_user_split_destroy
45 PurpleAccountUserSplit
*
46 purple_account_user_split_new(const gchar
*text
, const gchar
*default_value
, gchar sep
)
48 PurpleAccountUserSplit
*split
;
50 g_return_val_if_fail(text
!= NULL
, NULL
);
51 g_return_val_if_fail(sep
!= 0, NULL
);
53 split
= g_new0(PurpleAccountUserSplit
, 1);
55 split
->text
= g_strdup(text
);
56 split
->field_sep
= sep
;
57 split
->default_value
= g_strdup(default_value
);
58 split
->reverse
= TRUE
;
63 PurpleAccountUserSplit
*
64 purple_account_user_split_copy(PurpleAccountUserSplit
*split
) {
65 PurpleAccountUserSplit
*newsplit
= NULL
;
67 newsplit
= purple_account_user_split_new(split
->text
, split
->default_value
, split
->field_sep
);
69 newsplit
->reverse
= split
->reverse
;
70 newsplit
->constant
= split
->constant
;
77 purple_account_user_split_destroy(PurpleAccountUserSplit
*split
)
79 g_return_if_fail(split
!= NULL
);
82 g_free(split
->default_value
);
87 purple_account_user_split_get_text(const PurpleAccountUserSplit
*split
)
89 g_return_val_if_fail(split
!= NULL
, NULL
);
95 purple_account_user_split_get_default_value(const PurpleAccountUserSplit
*split
)
97 g_return_val_if_fail(split
!= NULL
, NULL
);
99 return split
->default_value
;
103 purple_account_user_split_get_separator(const PurpleAccountUserSplit
*split
)
105 g_return_val_if_fail(split
!= NULL
, 0);
107 return split
->field_sep
;
111 purple_account_user_split_get_reverse(const PurpleAccountUserSplit
*split
)
113 g_return_val_if_fail(split
!= NULL
, FALSE
);
115 return split
->reverse
;
119 purple_account_user_split_set_reverse(PurpleAccountUserSplit
*split
, gboolean reverse
)
121 g_return_if_fail(split
!= NULL
);
123 split
->reverse
= reverse
;
127 purple_account_user_split_is_constant(const PurpleAccountUserSplit
*split
)
129 g_return_val_if_fail(split
!= NULL
, FALSE
);
131 return split
->constant
;
135 purple_account_user_split_set_constant(PurpleAccountUserSplit
*split
,
138 g_return_if_fail(split
!= NULL
);
140 split
->constant
= constant
;