00001 /* 00002 * libopensync - A synchronization framework 00003 * Copyright (C) 2008 Daniel Gollub <dgollub@suse.de> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 */ 00020 00021 #include "opensync.h" 00022 #include "opensync_internals.h" 00023 00024 #include "opensync-plugin.h" 00025 #include "opensync_plugin_authentication_private.h" 00026 00027 OSyncPluginAuthentication *osync_plugin_authentication_new(OSyncError **error) 00028 { 00029 OSyncPluginAuthentication *auth = osync_try_malloc0(sizeof(OSyncPluginAuthentication), error); 00030 if (!auth) 00031 return NULL; 00032 00033 auth->ref_count = 1; 00034 00035 return auth; 00036 } 00037 00038 OSyncPluginAuthentication *osync_plugin_authentication_ref(OSyncPluginAuthentication *auth) 00039 { 00040 osync_assert(auth); 00041 00042 g_atomic_int_inc(&(auth->ref_count)); 00043 00044 return auth; 00045 } 00046 00047 void osync_plugin_authentication_unref(OSyncPluginAuthentication *auth) 00048 { 00049 osync_assert(auth); 00050 00051 if (g_atomic_int_dec_and_test(&(auth->ref_count))) { 00052 if (auth->username) 00053 osync_free(auth->username); 00054 00055 if (auth->password) 00056 osync_free(auth->password); 00057 00058 if (auth->reference) 00059 osync_free(auth->reference); 00060 00061 osync_free(auth); 00062 } 00063 } 00064 00065 osync_bool osync_plugin_authentication_option_is_supported(OSyncPluginAuthentication *auth, OSyncPluginAuthenticationOptionSupportedFlag flag) 00066 { 00067 osync_assert(auth); 00068 if (auth->supported_options & flag) 00069 return TRUE; 00070 00071 return FALSE; 00072 } 00073 00074 void osync_plugin_authentication_option_set_supported(OSyncPluginAuthentication *auth, OSyncPluginAuthenticationOptionSupportedFlags flags) 00075 { 00076 osync_assert(auth); 00077 auth->supported_options = flags; 00078 } 00079 00080 const char *osync_plugin_authentication_get_username(OSyncPluginAuthentication *auth) 00081 { 00082 osync_assert(auth); 00083 return auth->username; 00084 } 00085 00086 void osync_plugin_authentication_set_username(OSyncPluginAuthentication *auth, const char *username) 00087 { 00088 osync_assert(auth); 00089 00090 if (auth->username) 00091 osync_free(auth->username); 00092 00093 auth->username = osync_strdup(username); 00094 } 00095 00096 const char *osync_plugin_authentication_get_password(OSyncPluginAuthentication *auth) 00097 { 00098 osync_assert(auth); 00099 return auth->password; 00100 } 00101 00102 void osync_plugin_authentication_set_password(OSyncPluginAuthentication *auth, const char *password) 00103 { 00104 osync_assert(auth); 00105 00106 if (auth->password) 00107 osync_free(auth->password); 00108 00109 auth->password = osync_strdup(password); 00110 } 00111 00112 const char *osync_plugin_authentication_get_reference(OSyncPluginAuthentication *auth) 00113 { 00114 osync_assert(auth); 00115 return auth->reference; 00116 } 00117 00118 void osync_plugin_authentication_set_reference(OSyncPluginAuthentication *auth, const char *reference) 00119 { 00120 osync_assert(auth); 00121 00122 if (auth->reference) 00123 osync_free(auth->reference); 00124 00125 auth->reference = osync_strdup(reference); 00126 } 00127
1.5.7.1