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);
107 GWEN_Dialog_List_free(gui->activeDialogs);
112 if (gui->passwdStore)
141 assert(gui->refCount);
168 if (strcasecmp(gui->charSet,
"utf-8")!=0) {
171 "iconv not available, can not convert to \"%s\"",
176 ic=iconv_open(gui->charSet,
"UTF-8");
177 if (ic==((iconv_t)-1)) {
199 outbuf=(
char*)malloc(outLeft);
205 done=iconv(ic, &pInbuf, &inLeft, &pOutbuf, &outLeft);
206 if (done==(
size_t)-1) {
208 strerror(errno), errno);
236 while ((p=strchr(p,
'<'))) {
241 if (toupper(*t)==
'H') {
243 if (toupper(*t)==
'T') {
245 if (toupper(*t)==
'M') {
247 if (toupper(*t)==
'L') {
277 of=gui->messageBoxFn;
325 of=gui->progressStartFn;
326 gui->progressStartFn=f;
337 of=gui->progressAdvanceFn;
338 gui->progressAdvanceFn=f;
349 of=gui->progressSetTotalFn;
350 gui->progressSetTotalFn=f;
361 of=gui->progressLogFn;
362 gui->progressLogFn=f;
373 of=gui->progressEndFn;
374 gui->progressEndFn=f;
397 of=gui->getPasswordFn;
398 gui->getPasswordFn=f;
410 of=gui->setPasswordStatusFn;
411 gui->setPasswordStatusFn=f;
435 of=gui->waitForSocketsFn;
436 gui->waitForSocketsFn=f;
459 of=gui->execDialogFn;
471 of=gui->openDialogFn;
483 of=gui->closeDialogFn;
484 gui->closeDialogFn=f;
508 of=gui->readDialogPrefsFn;
509 gui->readDialogPrefsFn=f;
521 of=gui->writeDialogPrefsFn;
522 gui->writeDialogPrefsFn=f;
533 of=gui->getFileNameFn;
534 gui->getFileNameFn=f;
559 of=gui->keyDataFromTextOpenSslFn;
560 gui->keyDataFromTextOpenSslFn=f;
598 if (name) gui->name=strdup(name);
624 gui->charSet=strdup(s);
634 return gui->passwdStore;
642 if (gui->passwdStore && gui->passwdStore!=sto)
644 gui->passwdStore=sto;
656 gui->dbPasswords=dbPasswords;
657 gui->persistentPasswords=persistent;
663 return gui->dbPasswords;
697 char msgbuffer[2048];
702 rv=vsnprintf(msgbuffer,
sizeof(msgbuffer), fmt, list);
703 if (rv<0 || rv>=(
int)(
sizeof(msgbuffer))) {
705 rv, (
int)(
sizeof(msgbuffer)));
731 minLen, maxLen, guiid);
809 const char *fmt, ...) {
811 char msgbuffer[2048];
816 rv=vsnprintf(msgbuffer,
sizeof(msgbuffer), fmt, list);
817 if (rv<0 || rv>=(
int)(
sizeof(msgbuffer))) {
819 rv, (
int)(
sizeof(msgbuffer)));
893 token, pin, status, guiid);
904 strcasecmp(logDomain,
"gwenhywfar")==0)
933 GWEN_SOCKET_LIST2 *writeSockets,
962 I18N(
"Waiting for Data"),
963 "Waiting for data to become available",
969 GWEN_SOCKET_LIST2_ITERATOR *sit;
976 sit=GWEN_Socket_List2_First(readSockets);
980 s=GWEN_Socket_List2Iterator_Data(sit);
985 s=GWEN_Socket_List2Iterator_Next(sit);
987 GWEN_Socket_List2Iterator_free(sit);
993 sit=GWEN_Socket_List2_First(writeSockets);
997 s=GWEN_Socket_List2Iterator_Data(sit);
1002 s=GWEN_Socket_List2Iterator_Next(sit);
1004 GWEN_Socket_List2Iterator_free(sit);
1039 v=(int) difftime(t1, t0);
1074 const char *statusOn;
1075 const char *statusOff;
1081 const char *unknown;
1082 const char *commonName;
1083 const char *organizationName;
1084 const char *organizationalUnitName;
1085 const char *countryName;
1086 const char *localityName;
1087 const char *stateOrProvinceName;
1090 "The following certificate has been received:\n"
1092 "Organisation: %s\n"
1097 "Valid after : %s\n"
1098 "Valid until : %s\n"
1101 "Do you wish to accept this certificate?"
1105 " The following certificate has been received:"
1108 " <tr><td>Name</td><td>%s</td></tr>"
1109 " <tr><td>Organisation</td><td>%s</td></tr>"
1110 " <tr><td>Department</td><td>%s</td></tr>"
1111 " <tr><td>Country</td><td>%s</td></tr>"
1112 " <tr><td>City</td><td>%s</td></tr>"
1113 " <tr><td>State</td><td>%s</td></tr>"
1114 " <tr><td>Valid after</td><td>%s</td></tr>"
1115 " <tr><td>Valid until</td><td>%s</td></tr>"
1116 " <tr><td>Hash</td><td>%s</td></tr>"
1117 " <tr><td>Status</td><td>%s%s%s</td></tr>"
1120 " Do you wish to accept this certificate?"
1125 memset(dbuffer1, 0,
sizeof(dbuffer1));
1126 memset(dbuffer2, 0,
sizeof(dbuffer2));
1127 memset(varName, 0,
sizeof(varName));
1148 "Could not convert beforeDate to string");
1162 "Could not convert untilDate to string");
1170 statusOn=
"<font color=red>";
1171 statusOff=
"</font>";
1174 statusOn=
"<font color=green>";
1175 statusOff=
"</font>";
1178 unknown=
I18N(
"unknown");
1183 if (!organizationName)
1184 organizationName=unknown;
1186 if (!organizationalUnitName)
1187 organizationalUnitName=unknown;
1190 countryName=unknown;
1193 localityName=unknown;
1195 if (!stateOrProvinceName)
1196 stateOrProvinceName=unknown;
1200 snprintf(buffer,
sizeof(buffer)-1,
1204 organizationalUnitName,
1207 stateOrProvinceName,
1214 organizationalUnitName,
1217 stateOrProvinceName,
1228 I18N(
"Certificate Received"),
1230 I18N(
"Yes"),
I18N(
"No"), 0, guiid);
1244 unsigned char *buffer,
1245 unsigned int bufLength) {
1292 const char *patterns,
1309 const char *altName,
1328 const char *defaultProto,
1355 t=GWEN_ProgressData_Tree_GetParent(t);
1434 uint32_t progressFlags,
1443 id=++(gui->nextProgressId);
1446 progressFlags, title?title:
"(none)", (uint32_t) total, guiid);
1449 guiid=gui->lastProgressId;
1454 if (pdParent==
NULL) {
1457 title?title:
"no title",
1458 text?text:
"no text");
1466 GWEN_ProgressData_Tree_AddChild(pdParent, pd);
1468 GWEN_ProgressData_Tree_Add(gui->progressDataTree, pd);
1472 gui->lastProgressId=id;
1481 uint32_t parentPid=0;
1486 pid=gui->lastProgressId;
1506 previousPd=GWEN_ProgressData_Tree_GetParent(pd);
1512 previousPd=GWEN_ProgressData_Tree_GetParent(previousPd);
1563 else if (secondary==pd) {
1586 GWEN_ProgressData_Tree_Del(pd);
1600 pid=gui->lastProgressId;
1650 pid=gui->lastProgressId;
1698 if (level<=gui->minProgressLogLevel) {
1703 pid=gui->lastProgressId;
1823 id=++(gui->nextDialogId);
1840 GWEN_Dialog_List_Add(dlg, gui->activeDialogs);
1851 dlg=GWEN_Dialog_List_First(gui->activeDialogs);
1855 dlg=GWEN_Dialog_List_Next(dlg);
1859 dlg=GWEN_Dialog_List_Last(gui->activeDialogs);
1868 GWEN_Dialog_List_Del(dlg);
1877 const char *defaultProto,
1885 if (!(url && *url)) {
1908 if (!(addr && *addr)) {
1914 if (strcasecmp(s,
"http")==0 ||
1915 strcasecmp(s,
"https")==0) {
1934 if (strcasecmp(s,
"https")==0) {
2054 (gui->dbPasswords==
NULL)
2080 if (i>=minLen && i < maxLen) {
2081 memmove(buffer, s, i+1);
2093 if (gui->passwdStore) {
2113 "Password for [%s] missing in noninteractive mode, "
2148 I18N(
"Enforce PIN"),
2150 "You entered the same PIN twice.\n"
2151 "The PIN is marked as bad, do you want\n"
2155 "You entered the same PIN twice."
2158 "The PIN is marked as <b>bad</b>, "
2159 "do you want to use it anyway?"
2162 I18N(
"Yes, use anyway"),
2182 if (rv==1 && gui->passwdStore) {
2202 if (gui->passwdStore)
2204 if (gui->persistentPasswords==0)
2217 if (gui->passwdStore) {
2228 if (gui->persistentPasswords==0)
2242 return gui->minProgressLogLevel;
2249 gui->minProgressLogLevel=ll;