30 #define DISABLE_DEBUGLOG
45 #include <gwenhywfar/debug.h>
46 #include <gwenhywfar/dialog_be.h>
47 #include <gwenhywfar/mdigest.h>
48 #include <gwenhywfar/text.h>
49 #include <gwenhywfar/url.h>
50 #include <gwenhywfar/syncio_socket.h>
51 #include <gwenhywfar/syncio_buffered.h>
52 #include <gwenhywfar/syncio_tls.h>
53 #include <gwenhywfar/syncio_http.h>
86 gui->progressDataTree=GWEN_ProgressData_Tree_new();
87 gui->activeDialogs=GWEN_Dialog_List_new();
101 assert(gui->refCount);
102 if ((--gui->refCount)==0) {
105 GWEN_Dialog_List_free(gui->activeDialogs);
106 GWEN_ProgressData_Tree_free(gui->progressDataTree);
112 if (gui->passwdStore)
140 assert(gui->refCount);
167 if (strcasecmp(gui->charSet,
"utf-8")!=0) {
170 "iconv not available, can not convert to \"%s\"",
175 ic=iconv_open(gui->charSet,
"UTF-8");
176 if (ic==((iconv_t)-1)) {
198 outbuf=(
char*)malloc(outLeft);
204 done=iconv(ic, &pInbuf, &inLeft, &pOutbuf, &outLeft);
205 if (done==(
size_t)-1) {
207 strerror(errno), errno);
235 while ((p=strchr(p,
'<'))) {
240 if (toupper(*t)==
'H') {
242 if (toupper(*t)==
'T') {
244 if (toupper(*t)==
'M') {
246 if (toupper(*t)==
'L') {
276 of=gui->messageBoxFn;
324 of=gui->progressStartFn;
325 gui->progressStartFn=f;
336 of=gui->progressAdvanceFn;
337 gui->progressAdvanceFn=f;
348 of=gui->progressSetTotalFn;
349 gui->progressSetTotalFn=f;
360 of=gui->progressLogFn;
361 gui->progressLogFn=f;
372 of=gui->progressEndFn;
373 gui->progressEndFn=f;
396 of=gui->getPasswordFn;
397 gui->getPasswordFn=f;
409 of=gui->setPasswordStatusFn;
410 gui->setPasswordStatusFn=f;
434 of=gui->waitForSocketsFn;
435 gui->waitForSocketsFn=f;
458 of=gui->execDialogFn;
470 of=gui->openDialogFn;
482 of=gui->closeDialogFn;
483 gui->closeDialogFn=f;
507 of=gui->readDialogPrefsFn;
508 gui->readDialogPrefsFn=f;
520 of=gui->writeDialogPrefsFn;
521 gui->writeDialogPrefsFn=f;
532 of=gui->getFileNameFn;
533 gui->getFileNameFn=f;
558 of=gui->keyDataFromTextOpenSslFn;
559 gui->keyDataFromTextOpenSslFn=f;
597 if (name) gui->name=strdup(name);
623 gui->charSet=strdup(s);
633 return gui->passwdStore;
641 if (gui->passwdStore && gui->passwdStore!=sto)
643 gui->passwdStore=sto;
655 gui->dbPasswords=dbPasswords;
656 gui->persistentPasswords=persistent;
662 return gui->dbPasswords;
696 char msgbuffer[2048];
701 rv=vsnprintf(msgbuffer,
sizeof(msgbuffer), fmt, list);
702 if (rv<0 || rv>=(
int)(
sizeof(msgbuffer))) {
704 rv, (
int)(
sizeof(msgbuffer)));
730 minLen, maxLen, guiid);
808 const char *fmt, ...) {
810 char msgbuffer[2048];
815 rv=vsnprintf(msgbuffer,
sizeof(msgbuffer), fmt, list);
816 if (rv<0 || rv>=(
int)(
sizeof(msgbuffer))) {
818 rv, (
int)(
sizeof(msgbuffer)));
892 token, pin, status, guiid);
903 strcasecmp(logDomain,
"gwenhywfar")==0)
932 GWEN_SOCKET_LIST2 *writeSockets,
961 I18N(
"Waiting for Data"),
962 "Waiting for data to become available",
968 GWEN_SOCKET_LIST2_ITERATOR *sit;
975 sit=GWEN_Socket_List2_First(readSockets);
979 s=GWEN_Socket_List2Iterator_Data(sit);
984 s=GWEN_Socket_List2Iterator_Next(sit);
986 GWEN_Socket_List2Iterator_free(sit);
992 sit=GWEN_Socket_List2_First(writeSockets);
996 s=GWEN_Socket_List2Iterator_Data(sit);
1001 s=GWEN_Socket_List2Iterator_Next(sit);
1003 GWEN_Socket_List2Iterator_free(sit);
1038 v=(int) difftime(t1, t0);
1073 const char *statusOn;
1074 const char *statusOff;
1080 const char *unknown;
1081 const char *commonName;
1082 const char *organizationName;
1083 const char *organizationalUnitName;
1084 const char *countryName;
1085 const char *localityName;
1086 const char *stateOrProvinceName;
1089 "The following certificate has been received:\n"
1091 "Organisation: %s\n"
1096 "Valid after : %s\n"
1097 "Valid until : %s\n"
1100 "Do you wish to accept this certificate?"
1104 " The following certificate has been received:"
1107 " <tr><td>Name</td><td>%s</td></tr>"
1108 " <tr><td>Organisation</td><td>%s</td></tr>"
1109 " <tr><td>Department</td><td>%s</td></tr>"
1110 " <tr><td>Country</td><td>%s</td></tr>"
1111 " <tr><td>City</td><td>%s</td></tr>"
1112 " <tr><td>State</td><td>%s</td></tr>"
1113 " <tr><td>Valid after</td><td>%s</td></tr>"
1114 " <tr><td>Valid until</td><td>%s</td></tr>"
1115 " <tr><td>Hash</td><td>%s</td></tr>"
1116 " <tr><td>Status</td><td>%s%s%s</td></tr>"
1119 " Do you wish to accept this certificate?"
1124 memset(dbuffer1, 0,
sizeof(dbuffer1));
1125 memset(dbuffer2, 0,
sizeof(dbuffer2));
1126 memset(varName, 0,
sizeof(varName));
1147 "Could not convert beforeDate to string");
1161 "Could not convert untilDate to string");
1169 statusOn=
"<font color=red>";
1170 statusOff=
"</font>";
1173 statusOn=
"<font color=green>";
1174 statusOff=
"</font>";
1177 unknown=
I18N(
"unknown");
1182 if (!organizationName)
1183 organizationName=unknown;
1185 if (!organizationalUnitName)
1186 organizationalUnitName=unknown;
1189 countryName=unknown;
1192 localityName=unknown;
1194 if (!stateOrProvinceName)
1195 stateOrProvinceName=unknown;
1199 snprintf(buffer,
sizeof(buffer)-1,
1203 organizationalUnitName,
1206 stateOrProvinceName,
1213 organizationalUnitName,
1216 stateOrProvinceName,
1227 I18N(
"Certificate Received"),
1229 I18N(
"Yes"),
I18N(
"No"), 0, guiid);
1243 unsigned char *buffer,
1244 unsigned int bufLength) {
1291 const char *patterns,
1308 const char *altName,
1327 const char *defaultProto,
1354 t=GWEN_ProgressData_Tree_GetParent(t);
1433 uint32_t progressFlags,
1442 id=++(gui->nextProgressId);
1445 progressFlags, title?title:
"(none)", (uint32_t) total, guiid);
1448 guiid=gui->lastProgressId;
1453 if (pdParent==
NULL) {
1456 title?title:
"no title",
1457 text?text:
"no text");
1465 GWEN_ProgressData_Tree_AddChild(pdParent, pd);
1467 GWEN_ProgressData_Tree_Add(gui->progressDataTree, pd);
1471 gui->lastProgressId=id;
1480 uint32_t parentPid=0;
1485 pid=gui->lastProgressId;
1505 previousPd=GWEN_ProgressData_Tree_GetParent(pd);
1511 previousPd=GWEN_ProgressData_Tree_GetParent(previousPd);
1562 else if (secondary==pd) {
1585 GWEN_ProgressData_Tree_Del(pd);
1599 pid=gui->lastProgressId;
1649 pid=gui->lastProgressId;
1697 if (level<=gui->minProgressLogLevel) {
1702 pid=gui->lastProgressId;
1822 id=++(gui->nextDialogId);
1839 GWEN_Dialog_List_Add(dlg, gui->activeDialogs);
1850 dlg=GWEN_Dialog_List_First(gui->activeDialogs);
1854 dlg=GWEN_Dialog_List_Next(dlg);
1858 dlg=GWEN_Dialog_List_Last(gui->activeDialogs);
1867 GWEN_Dialog_List_Del(dlg);
1876 const char *defaultProto,
1884 if (!(url && *url)) {
1907 if (!(addr && *addr)) {
1913 if (strcasecmp(s,
"http")==0 ||
1914 strcasecmp(s,
"https")==0) {
1933 if (strcasecmp(s,
"https")==0) {
2053 (gui->dbPasswords==
NULL)
2079 if (i>=minLen && i < maxLen) {
2080 memmove(buffer, s, i+1);
2092 if (gui->passwdStore) {
2112 "Password for [%s] missing in noninteractive mode, "
2147 I18N(
"Enforce PIN"),
2149 "You entered the same PIN twice.\n"
2150 "The PIN is marked as bad, do you want\n"
2154 "You entered the same PIN twice."
2157 "The PIN is marked as <b>bad</b>, "
2158 "do you want to use it anyway?"
2161 I18N(
"Yes, use anyway"),
2181 if (rv==1 && gui->passwdStore) {
2201 if (gui->passwdStore)
2203 if (gui->persistentPasswords==0)
2216 if (gui->passwdStore) {
2227 if (gui->persistentPasswords==0)
2241 return gui->minProgressLogLevel;
2248 gui->minProgressLogLevel=ll;