Git init
[framework/location/libslp-location.git] / location / location-address.c
1 /*
2  * libslp-location
3  *
4  * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7  *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "location/location-address.h"
27 #include "location/location-log.h"
28
29 GType
30 location_address_get_type (void)
31 {
32         static volatile gsize type_volatile = 0;
33         if(g_once_init_enter(&type_volatile)) {
34                 GType type = g_boxed_type_register_static (
35                         g_intern_static_string ("LocationAddress"),
36                         (GBoxedCopyFunc) location_address_copy,
37                         (GBoxedFreeFunc) location_address_free);
38                 g_once_init_leave(&type_volatile, type);
39         }
40         return type_volatile;
41 }
42
43 EXPORT_API LocationAddress*
44 location_address_new (const gchar *building_number,
45         const gchar *street,
46         const gchar *district,
47         const gchar *city,
48         const gchar *state,
49         const gchar *country_code,
50         const gchar *postal_code)
51 {
52         LocationAddress* address = g_slice_new0(LocationAddress);
53
54         address->building_number = g_strdup(building_number);
55         address->street = g_strdup(street);
56         address->district = g_strdup(district);
57         address->city = g_strdup(city);
58         address->state = g_strdup(state);
59         address->country_code = g_strdup(country_code);
60         address->postal_code = g_strdup(postal_code);
61
62         return address;
63 }
64
65 EXPORT_API void
66 location_address_free (LocationAddress* address)
67 {
68         g_return_if_fail(address);
69         g_free(address->building_number);
70         g_free(address->street);
71         g_free(address->district);
72         g_free(address->city);
73         g_free(address->state);
74         g_free(address->country_code);
75         g_free(address->postal_code);
76         g_slice_free(LocationAddress, address);
77 }
78
79 EXPORT_API LocationAddress*
80 location_address_copy (const LocationAddress *address)
81 {
82         g_return_val_if_fail(address, NULL);
83         return location_address_new(address->building_number,
84                                                                 address->street,
85                                                                 address->district,
86                                                                 address->city,
87                                                                 address->state,
88                                                                 address->country_code,
89                                                                 address->postal_code);
90 }