#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include <liberregxml/erregapi.h>
#include "setupLog.h"
#include "iLiadPCConnectData.h"
#include "settings.h"
Go to the source code of this file.
Functions | |
| static guint | iLiad_pc_connect_add_profile (void) |
| void | iLiad_pc_connect_data_init (void) |
| void | iLiad_pc_connect_data_destroy (void) |
| const regPCProfile_t * | iLiad_pc_connect_get_profiledata (const gint profile_index) |
| gboolean | iLiad_pc_connect_set_profile_field (gint profile_index, pc_fieldtype_t field, const char *value) |
| void | iLiad_pc_connect_data_store (void) |
Variables | |
| static regPCConfig_t * | g_pc_connect_config = NULL |
| static regPCProfile_t ** | g_pc_connect_settings = NULL |
| static gboolean | g_pc_connect_changed = FALSE |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
<File description>="">
Definition in file iLiadPCConnectData.c.
| static guint iLiad_pc_connect_add_profile | ( | void | ) | [static] |
Definition at line 185 of file iLiadPCConnectData.c.
00186 { 00187 ST_LOGPRINTF("entry"); 00188 00189 guint profile_index = g_pc_connect_config->size; 00190 00191 // add one pc ID 00192 gchar **newList = g_renew(gchar *, g_pc_connect_config->pcList, profile_index + 1); 00193 g_pc_connect_config->pcList = newList; 00194 g_pc_connect_config->pcList[profile_index] = g_strdup_printf("PC_%d", profile_index); 00195 00196 // add pc setting 00197 regPCProfile_t **newSettings = g_renew(regPCProfile_t *, g_pc_connect_settings, profile_index + 1); 00198 g_pc_connect_settings = newSettings; 00199 g_pc_connect_settings[profile_index] = NULL; 00200 g_pc_connect_config->size = profile_index + 1; 00201 00202 // report number of profiles 00203 ST_LOGPRINTF("g_pc_connect_config->size=%d", g_pc_connect_config->size); 00204 return g_pc_connect_config->size; 00205 }
| void iLiad_pc_connect_data_destroy | ( | void | ) |
Definition at line 86 of file iLiadPCConnectData.c.
00087 { 00088 ST_LOGPRINTF("entry"); 00089 00090 if (g_pc_connect_config) 00091 { 00092 erRegFreePCProfiles(g_pc_connect_config, g_pc_connect_settings); 00093 g_pc_connect_settings = NULL; 00094 g_pc_connect_config = NULL; 00095 } 00096 }

| void iLiad_pc_connect_data_init | ( | void | ) |
Definition at line 58 of file iLiadPCConnectData.c.
00059 { 00060 regPCProfile_t* setting = NULL; 00061 00062 ST_LOGPRINTF("entry"); 00063 00064 iLiad_pc_connect_data_destroy(); 00065 00066 // read all pc connect profiles from registry 00067 erRegGetPCProfiles(&g_pc_connect_config, &g_pc_connect_settings); 00068 00069 // make sure at least one profile is present 00070 if (g_pc_connect_config->size == 0) 00071 { 00072 ST_WARNPRINTF("no PC profiles, create one empty profile"); 00073 iLiad_pc_connect_add_profile(); 00074 setting = g_new0(regPCProfile_t, 1); 00075 g_assert(setting != NULL); 00076 setting->name = strdup(""); 00077 setting->pcname = strdup(""); 00078 setting->sharename = strdup(""); 00079 setting->workgroup = strdup(""); 00080 setting->username = strdup(""); 00081 setting->password = strdup(""); 00082 g_pc_connect_settings[0] = setting; 00083 } 00084 }

| void iLiad_pc_connect_data_store | ( | void | ) |
Definition at line 163 of file iLiadPCConnectData.c.
00164 { 00165 ST_LOGPRINTF("entry"); 00166 00167 if (g_pc_connect_changed == FALSE) 00168 { 00169 // nothing to save 00170 ST_LOGPRINTF("nothing to save"); 00171 return; 00172 } 00173 00174 // write our pc profiles to registry 00175 prepare_registry_write(); 00176 00177 const regPCProfile_t** p = (const regPCProfile_t**)g_pc_connect_settings; // const_cast 00178 erRegSetPCProfiles(g_pc_connect_config, p); 00179 00180 g_pc_connect_changed = FALSE; 00181 00182 do_registry_write(); 00183 }

| const regPCProfile_t* iLiad_pc_connect_get_profiledata | ( | const gint | profile_index | ) |
Definition at line 98 of file iLiadPCConnectData.c.
00099 { 00100 ST_LOGPRINTF("entry: index [%d]", profile_index); 00101 00102 g_return_val_if_fail((g_pc_connect_config != NULL), NULL); 00103 00104 if (profile_index < g_pc_connect_config->size) 00105 { 00106 return g_pc_connect_settings[profile_index]; 00107 } 00108 else 00109 { 00110 return NULL; 00111 } 00112 }
| gboolean iLiad_pc_connect_set_profile_field | ( | gint | profile_index, | |
| pc_fieldtype_t | field, | |||
| const char * | value | |||
| ) |
Definition at line 114 of file iLiadPCConnectData.c.
00115 { 00116 gchar** cpp; 00117 00118 ST_LOGPRINTF("entry: index [%d] field [%d] value [%s] size [%d]", profile_index, field, value, g_pc_connect_config->size); 00119 00120 g_return_val_if_fail((g_pc_connect_config != NULL), FALSE); 00121 g_return_val_if_fail((profile_index < g_pc_connect_config->size), FALSE); 00122 00123 if (value == NULL) 00124 { 00125 value = ""; 00126 } 00127 00128 // remember new value 00129 switch (field) 00130 { 00131 case e_pcfield_profile_name: 00132 cpp = &(g_pc_connect_settings[profile_index]->name); 00133 break; 00134 case e_pcfield_pcname: 00135 cpp = &(g_pc_connect_settings[profile_index]->pcname); 00136 break; 00137 case e_pcfield_sharename: 00138 cpp = &(g_pc_connect_settings[profile_index]->sharename); 00139 break; 00140 case e_pcfield_workgroup: 00141 cpp = &(g_pc_connect_settings[profile_index]->workgroup); 00142 break; 00143 case e_pcfield_username: 00144 cpp = &(g_pc_connect_settings[profile_index]->username); 00145 break; 00146 case e_pcfield_password: 00147 cpp = &(g_pc_connect_settings[profile_index]->password); 00148 break; 00149 default: 00150 g_assert_not_reached(); 00151 return FALSE; 00152 } 00153 if (*cpp) 00154 { 00155 g_free(*cpp); 00156 } 00157 *cpp = g_strdup(value); 00158 00159 g_pc_connect_changed = TRUE; 00160 return TRUE; 00161 }
gboolean g_pc_connect_changed = FALSE [static] |
Definition at line 51 of file iLiadPCConnectData.c.
regPCConfig_t* g_pc_connect_config = NULL [static] |
Definition at line 48 of file iLiadPCConnectData.c.
regPCProfile_t** g_pc_connect_settings = NULL [static] |
Definition at line 49 of file iLiadPCConnectData.c.
1.5.6