~ubuntu-branches/ubuntu/breezy/evolution-data-server/breezy

« back to all changes in this revision

Viewing changes to camel/camel-address.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-10-10 11:30:56 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051010113056-rb4vj4kbs8yxft85
Tags: 1.4.1-0ubuntu3
* debian/patches/camel-imap-store.c.patch:
  - Ubuntu 17465: apply patch from
  http://bugzilla.gnome.org/attachment.cgi?id=53234&action=view
  (additional NULL pointer check)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 *  Authors: Michael Zucchi <notzed@ximian.com>
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of version 2 of the GNU General Public
 
7
 * modify it under the terms of version 2 of the GNU Lesser General Public
8
8
 * License as published by the Free Software Foundation.
9
9
 *
10
10
 * This program is distributed in the hope that it will be useful,
12
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
13
 * General Public License for more details.
14
14
 *
15
 
 * You should have received a copy of the GNU General Public
 
15
 * You should have received a copy of the GNU Lesser General Public
16
16
 * License along with this program; if not, write to the
17
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
18
 * Boston, MA 02111-1307, USA.
67
67
/**
68
68
 * camel_address_new:
69
69
 *
70
 
 * Create a new CamelAddress object.
 
70
 * Create a new #CamelAddress object.
71
71
 * 
72
 
 * Return value: A new CamelAddress widget.
 
72
 * Returns a new #CamelAddress object
73
73
 **/
74
74
CamelAddress *
75
75
camel_address_new (void)
78
78
        return new;
79
79
}
80
80
 
 
81
 
81
82
/**
82
83
 * camel_address_new_clone:
83
 
 * @in: 
 
84
 * @addr: a #CamelAddress object
84
85
 * 
85
86
 * Clone an existing address type.
86
87
 * 
87
 
 * Return value: 
 
88
 * Returns the cloned address
88
89
 **/
89
90
CamelAddress *
90
 
camel_address_new_clone(const CamelAddress *in)
 
91
camel_address_new_clone (const CamelAddress *addr)
91
92
{
92
 
        CamelAddress *new = CAMEL_ADDRESS(camel_object_new(CAMEL_OBJECT_GET_TYPE(in)));
 
93
        CamelAddress *new = CAMEL_ADDRESS(camel_object_new(CAMEL_OBJECT_GET_TYPE(addr)));
93
94
 
94
 
        camel_address_cat(new, in);
 
95
        camel_address_cat(new, addr);
95
96
        return new;
96
97
}
97
98
 
 
99
 
98
100
/**
99
101
 * camel_address_length:
100
 
 * @a: 
101
 
 * 
102
 
 * Return the number of addresses stored in the address @a.
103
 
 * 
104
 
 * Return value: 
 
102
 * @addr: a #CamelAddress object
 
103
 * 
 
104
 * Get the number of addresses stored in the address @addr.
 
105
 * 
 
106
 * Returns the number of addresses contained in @addr
105
107
 **/
106
108
int
107
 
camel_address_length(CamelAddress *a)
 
109
camel_address_length (CamelAddress *addr)
108
110
{
109
 
        return a->addresses->len;
 
111
        return addr->addresses->len;
110
112
}
111
113
 
 
114
 
112
115
/**
113
116
 * camel_address_decode:
114
 
 * @a: An address.
115
 
 * @raw: Raw address description.
116
 
 * 
 
117
 * @addr: a #CamelAddress object
 
118
 * @raw: raw address description
 
119
 *
117
120
 * Construct a new address from a raw address field.
118
 
 * 
119
 
 * Return value: Returns the number of addresses found,
120
 
 * or -1 if the addresses could not be parsed fully.
 
121
 *
 
122
 * Returns the number of addresses parsed or %-1 on fail
121
123
 **/
122
124
int
123
 
camel_address_decode    (CamelAddress *a, const char *raw)
 
125
camel_address_decode (CamelAddress *addr, const char *raw)
124
126
{
125
 
        g_return_val_if_fail(CAMEL_IS_ADDRESS(a), -1);
 
127
        g_return_val_if_fail(CAMEL_IS_ADDRESS(addr), -1);
126
128
 
127
 
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->decode(a, raw);
 
129
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (addr))->decode(addr, raw);
128
130
}
129
131
 
 
132
 
130
133
/**
131
134
 * camel_address_encode:
132
 
 * @a: 
 
135
 * @addr: a #CamelAddress object
133
136
 * 
134
137
 * Encode an address in a format suitable for a raw header.
135
138
 * 
136
 
 * Return value: The encoded address.
 
139
 * Returns the encoded address
137
140
 **/
138
141
char *
139
 
camel_address_encode    (CamelAddress *a)
 
142
camel_address_encode (CamelAddress *addr)
140
143
{
141
 
        g_return_val_if_fail(CAMEL_IS_ADDRESS(a), NULL);
 
144
        g_return_val_if_fail(CAMEL_IS_ADDRESS(addr), NULL);
142
145
 
143
 
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->encode(a);
 
146
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (addr))->encode(addr);
144
147
}
145
148
 
 
149
 
146
150
/**
147
151
 * camel_address_unformat:
148
 
 * @a: 
149
 
 * @raw: 
 
152
 * @addr: a #CamelAddress object
 
153
 * @raw: raw address description
150
154
 * 
151
155
 * Attempt to convert a previously formatted and/or edited
152
156
 * address back into internal form.
153
157
 * 
154
 
 * Return value: -1 if it could not be parsed, or the number
155
 
 * of valid addresses found.
 
158
 * Returns the number of addresses parsed or %-1 on fail
156
159
 **/
157
160
int
158
 
camel_address_unformat(CamelAddress *a, const char *raw)
 
161
camel_address_unformat(CamelAddress *addr, const char *raw)
159
162
{
160
 
        g_return_val_if_fail(CAMEL_IS_ADDRESS(a), -1);
 
163
        g_return_val_if_fail(CAMEL_IS_ADDRESS(addr), -1);
161
164
 
162
 
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->unformat(a, raw);
 
165
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (addr))->unformat(addr, raw);
163
166
}
164
167
 
 
168
 
165
169
/**
166
170
 * camel_address_format:
167
 
 * @a: 
 
171
 * @addr: a #CamelAddress object
168
172
 * 
169
173
 * Format an address in a format suitable for display.
170
174
 * 
171
 
 * Return value: The formatted address.
 
175
 * Returns a newly allocated string containing the formatted addresses
172
176
 **/
173
177
char *
174
 
camel_address_format    (CamelAddress *a)
 
178
camel_address_format (CamelAddress *addr)
175
179
{
176
 
        if (a == NULL)
177
 
                return NULL;
178
 
 
179
 
        g_return_val_if_fail(CAMEL_IS_ADDRESS(a), NULL);
180
 
 
181
 
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->format(a);
 
180
        g_return_val_if_fail(CAMEL_IS_ADDRESS(addr), NULL);
 
181
 
 
182
        return CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (addr))->format(addr);
182
183
}
183
184
 
 
185
 
184
186
/**
185
187
 * camel_address_cat:
186
 
 * @dest: 
187
 
 * @source: 
 
188
 * @dest: destination #CamelAddress object
 
189
 * @source: source #CamelAddress object
188
190
 * 
189
 
 * Concatenate one address onto another.  The addresses must
 
191
 * Concatenate one address onto another. The addresses must
190
192
 * be of the same type.
191
193
 * 
192
 
 * Return value: 
 
194
 * Returns the number of addresses concatenated
193
195
 **/
194
196
int
195
 
camel_address_cat       (CamelAddress *dest, const CamelAddress *source)
 
197
camel_address_cat (CamelAddress *dest, const CamelAddress *source)
196
198
{
197
199
        g_return_val_if_fail(CAMEL_IS_ADDRESS(dest), -1);
198
200
        g_return_val_if_fail(CAMEL_IS_ADDRESS(source), -1);
200
202
        return CAMEL_ADDRESS_CLASS(CAMEL_OBJECT_GET_CLASS(dest))->cat(dest, source);
201
203
}
202
204
 
 
205
 
203
206
/**
204
207
 * camel_address_copy:
205
 
 * @dest: 
206
 
 * @source: 
207
 
 * 
208
 
 * Copy an address contents.
209
 
 * 
210
 
 * Return value: 
 
208
 * @dest: destination #CamelAddress object
 
209
 * @source: source #CamelAddress object
 
210
 * 
 
211
 * Copy the contents of one address into another.
 
212
 * 
 
213
 * Returns the number of addresses copied
211
214
 **/
212
215
int
213
 
camel_address_copy      (CamelAddress *dest, const CamelAddress *source)
 
216
camel_address_copy (CamelAddress *dest, const CamelAddress *source)
214
217
{
215
218
        g_return_val_if_fail(CAMEL_IS_ADDRESS(dest), -1);
216
219
        g_return_val_if_fail(CAMEL_IS_ADDRESS(source), -1);
219
222
        return camel_address_cat(dest, source);
220
223
}
221
224
 
 
225
 
222
226
/**
223
227
 * camel_address_remove:
224
 
 * @a: 
225
 
 * @index: The address to remove, use -1 to remove all address.
 
228
 * @addr: a #CamelAddress object
 
229
 * @index: The address to remove, use %-1 to remove all address.
226
230
 * 
227
231
 * Remove an address by index, or all addresses.
228
232
 **/
229
233
void
230
 
camel_address_remove    (CamelAddress *a, int index)
 
234
camel_address_remove (CamelAddress *addr, int index)
231
235
{
232
 
        g_return_if_fail(CAMEL_IS_ADDRESS(a));
 
236
        g_return_if_fail(CAMEL_IS_ADDRESS(addr));
233
237
 
234
238
        if (index == -1) {
235
 
                for (index=a->addresses->len; index>-1; index--)
236
 
                        CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->remove(a, index);
 
239
                for (index = addr->addresses->len; index>-1; index--)
 
240
                        CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (addr))->remove(addr, index);
237
241
        } else {
238
 
                CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (a))->remove(a, index);
 
242
                CAMEL_ADDRESS_CLASS (CAMEL_OBJECT_GET_CLASS (addr))->remove(addr, index);
239
243
        }
240
244
}