gui.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  $RCSfile$
00003  -------------------
00004  cvs         : $Id: bio_buffer.c 1102 2006-12-30 19:39:37Z martin $
00005  begin       : Fri Feb 07 2003
00006  copyright   : (C) 2003 by Martin Preuss
00007  email       : martin@libchipcard.de
00008 
00009  ***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #ifdef HAVE_CONFIG_H
00030 # include <config.h>
00031 #endif
00032 
00033 
00034 #include "gui_p.h"
00035 #include "i18n_l.h"
00036 
00037 #include <gwenhywfar/debug.h>
00038 
00039 
00040 
00041 static GWEN_GUI *gwenhywfar_gui=NULL;
00042 
00043 
00044 GWEN_INHERIT_FUNCTIONS(GWEN_GUI)
00045 
00046 
00047 
00048 GWEN_GUI *GWEN_Gui_new() {
00049   GWEN_GUI *gui;
00050 
00051   GWEN_NEW_OBJECT(GWEN_GUI, gui);
00052   GWEN_INHERIT_INIT(GWEN_GUI, gui);
00053   gui->refCount=1;
00054 
00055   gui->checkCertFn=GWEN_Gui_CheckCertBuiltIn;
00056 
00057   return gui;
00058 }
00059 
00060 
00061 
00062 void GWEN_Gui_free(GWEN_GUI *gui) {
00063   if (gui) {
00064     assert(gui->refCount);
00065     if ((--gui->refCount)==0) {
00066       GWEN_INHERIT_FINI(GWEN_GUI, gui);
00067       GWEN_FREE_OBJECT(gui);
00068     }
00069   }
00070 }
00071 
00072 
00073 
00074 void GWEN_Gui_Attach(GWEN_GUI *gui) {
00075   assert(gui);
00076   assert(gui->refCount);
00077   gui->refCount++;
00078 }
00079 
00080 
00081 
00082 void GWEN_Gui_SetGui(GWEN_GUI *gui) {
00083   if (gui)
00084     GWEN_Gui_Attach(gui);
00085   if (gwenhywfar_gui)
00086     GWEN_Gui_free(gwenhywfar_gui);
00087   gwenhywfar_gui=gui;
00088 }
00089 
00090 
00091 
00092 GWEN_GUI_MESSAGEBOX_FN GWEN_Gui_SetMessageBoxFn(GWEN_GUI *gui,
00093                                                 GWEN_GUI_MESSAGEBOX_FN f){
00094   GWEN_GUI_MESSAGEBOX_FN of;
00095 
00096   assert(gui);
00097   of=gui->messageBoxFn;
00098   gui->messageBoxFn=f;
00099   return of;
00100 }
00101 
00102 
00103 
00104 GWEN_GUI_INPUTBOX_FN GWEN_Gui_SetInputBoxFn(GWEN_GUI *gui,
00105                                             GWEN_GUI_INPUTBOX_FN f){
00106   GWEN_GUI_INPUTBOX_FN of;
00107 
00108   assert(gui);
00109   of=gui->inputBoxFn;
00110   gui->inputBoxFn=f;
00111   return of;
00112 }
00113 
00114 
00115 
00116 GWEN_GUI_SHOWBOX_FN GWEN_Gui_SetShowBoxFn(GWEN_GUI *gui,
00117                                           GWEN_GUI_SHOWBOX_FN f){
00118   GWEN_GUI_SHOWBOX_FN of;
00119 
00120   assert(gui);
00121   of=gui->showBoxFn;
00122   gui->showBoxFn=f;
00123   return of;
00124 }
00125 
00126 
00127 
00128 GWEN_GUI_HIDEBOX_FN GWEN_Gui_SetHideBoxFn(GWEN_GUI *gui,
00129                                           GWEN_GUI_HIDEBOX_FN f){
00130   GWEN_GUI_HIDEBOX_FN of;
00131 
00132   assert(gui);
00133   of=gui->hideBoxFn;
00134   gui->hideBoxFn=f;
00135   return of;
00136 }
00137 
00138 
00139 
00140 GWEN_GUI_PROGRESS_START_FN
00141 GWEN_Gui_SetProgressStartFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_START_FN f){
00142   GWEN_GUI_PROGRESS_START_FN of;
00143 
00144   assert(gui);
00145   of=gui->progressStartFn;
00146   gui->progressStartFn=f;
00147   return of;
00148 }
00149 
00150 
00151 
00152 GWEN_GUI_PROGRESS_ADVANCE_FN
00153 GWEN_Gui_SetProgressAdvanceFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_ADVANCE_FN f){
00154   GWEN_GUI_PROGRESS_ADVANCE_FN of;
00155 
00156   assert(gui);
00157   of=gui->progressAdvanceFn;
00158   gui->progressAdvanceFn=f;
00159   return of;
00160 }
00161 
00162 
00163 
00164 GWEN_GUI_PROGRESS_LOG_FN
00165 GWEN_Gui_SetProgressLogFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_LOG_FN f){
00166   GWEN_GUI_PROGRESS_LOG_FN of;
00167 
00168   assert(gui);
00169   of=gui->progressLogFn;
00170   gui->progressLogFn=f;
00171   return of;
00172 }
00173 
00174 
00175 
00176 GWEN_GUI_PROGRESS_END_FN
00177 GWEN_Gui_SetProgressEndFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_END_FN f){
00178   GWEN_GUI_PROGRESS_END_FN of;
00179 
00180   assert(gui);
00181   of=gui->progressEndFn;
00182   gui->progressEndFn=f;
00183   return of;
00184 }
00185 
00186 
00187 
00188 GWEN_GUI_PRINT_FN GWEN_Gui_SetPrintFn(GWEN_GUI *gui,
00189                                       GWEN_GUI_PRINT_FN f){
00190   GWEN_GUI_PRINT_FN of;
00191 
00192   assert(gui);
00193   of=gui->printFn;
00194   gui->printFn=f;
00195   return of;
00196 }
00197 
00198 
00199 
00200 GWEN_GUI_GETPASSWORD_FN GWEN_Gui_SetGetPasswordFn(GWEN_GUI *gui,
00201                                                   GWEN_GUI_GETPASSWORD_FN f) {
00202   GWEN_GUI_GETPASSWORD_FN of;
00203 
00204   assert(gui);
00205   of=gui->getPasswordFn;
00206   gui->getPasswordFn=f;
00207   return of;
00208 }
00209 
00210 
00211 
00212 GWEN_GUI_SETPASSWORDSTATUS_FN
00213 GWEN_Gui_SetSetPasswordStatusFn(GWEN_GUI *gui,
00214                                 GWEN_GUI_SETPASSWORDSTATUS_FN f) {
00215   GWEN_GUI_SETPASSWORDSTATUS_FN of;
00216 
00217   assert(gui);
00218   of=gui->setPasswordStatusFn;
00219   gui->setPasswordStatusFn=f;
00220   return of;
00221 }
00222 
00223 
00224 
00225 GWEN_GUI_LOG_HOOK_FN GWEN_Gui_SetLogHookFn(GWEN_GUI *gui,
00226                                            GWEN_GUI_LOG_HOOK_FN f) {
00227   GWEN_GUI_LOG_HOOK_FN of;
00228 
00229   assert(gui);
00230   of=gui->logHookFn;
00231   gui->logHookFn=f;
00232 
00233   return of;
00234 }
00235 
00236 
00237 
00238 GWEN_GUI_WAITFORSOCKETS_FN GWEN_Gui_SetWaitForSocketsFn(GWEN_GUI *gui,
00239                                                         GWEN_GUI_WAITFORSOCKETS_FN f) {
00240   GWEN_GUI_WAITFORSOCKETS_FN of;
00241 
00242   assert(gui);
00243   of=gui->waitForSocketsFn;
00244   gui->waitForSocketsFn=f;
00245 
00246   return of;
00247 }
00248 
00249 
00250 
00251 GWEN_GUI_CHECKCERT_FN GWEN_Gui_SetCheckCertFn(GWEN_GUI *gui, GWEN_GUI_CHECKCERT_FN f) {
00252   GWEN_GUI_CHECKCERT_FN of;
00253 
00254   assert(gui);
00255   of=gui->checkCertFn;
00256   gui->checkCertFn=f;
00257 
00258   return of;
00259 }
00260 
00261 
00262 
00263 GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN
00264 GWEN_Gui_SetKeyDataFromTextOpenSslFn(GWEN_GUI *gui,
00265                                      GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN f) {
00266   GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN of;
00267 
00268   assert(gui);
00269   of=gui->keyDataFromTextOpenSslFn;
00270   gui->keyDataFromTextOpenSslFn=f;
00271 
00272   return of;
00273 
00274 }
00275 
00276 
00277 
00278 
00279 
00280 
00281 
00282 int GWEN_Gui_MessageBox(uint32_t flags,
00283                         const char *title,
00284                         const char *text,
00285                         const char *b1,
00286                         const char *b2,
00287                         const char *b3,
00288                         uint32_t guiid) {
00289   if (gwenhywfar_gui && gwenhywfar_gui->messageBoxFn)
00290     return gwenhywfar_gui->messageBoxFn(gwenhywfar_gui,
00291                                         flags,
00292                                         title,
00293                                         text,
00294                                         b1, b2, b3, guiid);
00295   return GWEN_ERROR_NOT_IMPLEMENTED;
00296 }
00297 
00298 
00299 
00300 int GWEN_Gui_InputBox(uint32_t flags,
00301                       const char *title,
00302                       const char *text,
00303                       char *buffer,
00304                       int minLen,
00305                       int maxLen,
00306                       uint32_t guiid) {
00307   if (gwenhywfar_gui && gwenhywfar_gui->inputBoxFn)
00308     return gwenhywfar_gui->inputBoxFn(gwenhywfar_gui,
00309                                       flags,
00310                                       title,
00311                                       text,
00312                                       buffer,
00313                                       minLen, maxLen, guiid);
00314   return GWEN_ERROR_NOT_IMPLEMENTED;
00315 }
00316 
00317 
00318 
00319 uint32_t GWEN_Gui_ShowBox(uint32_t flags,
00320                           const char *title,
00321                           const char *text,
00322                           uint32_t guiid) {
00323   if (gwenhywfar_gui && gwenhywfar_gui->showBoxFn)
00324     return gwenhywfar_gui->showBoxFn(gwenhywfar_gui,
00325                                      flags,
00326                                      title,
00327                                      text,
00328                                      guiid);
00329   return 0;
00330 }
00331 
00332 
00333 
00334 void GWEN_Gui_HideBox(uint32_t id) {
00335   if (gwenhywfar_gui && gwenhywfar_gui->hideBoxFn)
00336     return gwenhywfar_gui->hideBoxFn(gwenhywfar_gui, id);
00337 }
00338 
00339 
00340 
00341 uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags,
00342                                 const char *title,
00343                                 const char *text,
00344                                 uint64_t total,
00345                                 uint32_t guiid) {
00346   if (gwenhywfar_gui && gwenhywfar_gui->progressStartFn)
00347     return gwenhywfar_gui->progressStartFn(gwenhywfar_gui,
00348                                            progressFlags,
00349                                            title,
00350                                            text,
00351                                            total,
00352                                            guiid);
00353   return 0;
00354 }
00355 
00356 
00357 
00358 int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress) {
00359   if (gwenhywfar_gui && gwenhywfar_gui->progressAdvanceFn)
00360     return gwenhywfar_gui->progressAdvanceFn(gwenhywfar_gui,
00361                                              id,
00362                                              progress);
00363   return 0;
00364 }
00365 
00366 
00367 
00368 int GWEN_Gui_ProgressLog(uint32_t id,
00369                          GWEN_LOGGER_LEVEL level,
00370                          const char *text) {
00371   if (gwenhywfar_gui && gwenhywfar_gui->progressLogFn)
00372     return gwenhywfar_gui->progressLogFn(gwenhywfar_gui,
00373                                          id, level, text);
00374   return 0;
00375 }
00376 
00377 
00378 
00379 int GWEN_Gui_ProgressEnd(uint32_t id) {
00380   if (gwenhywfar_gui && gwenhywfar_gui->progressEndFn)
00381     return gwenhywfar_gui->progressEndFn(gwenhywfar_gui, id);
00382   return GWEN_ERROR_NOT_IMPLEMENTED;
00383 }
00384 
00385 
00386 
00387 int GWEN_Gui_Print(const char *docTitle,
00388                    const char *docType,
00389                    const char *descr,
00390                    const char *text,
00391                    uint32_t guiid) {
00392   if (gwenhywfar_gui && gwenhywfar_gui->printFn)
00393     return gwenhywfar_gui->printFn(gwenhywfar_gui,
00394                                    docTitle,
00395                                    docType,
00396                                    descr,
00397                                    text,
00398                                    guiid);
00399   return GWEN_ERROR_NOT_IMPLEMENTED;
00400 }
00401 
00402 
00403 
00404 int GWEN_Gui_GetPassword(uint32_t flags,
00405                          const char *token,
00406                          const char *title,
00407                          const char *text,
00408                          char *buffer,
00409                          int minLen,
00410                          int maxLen,
00411                          uint32_t guiid) {
00412   if (gwenhywfar_gui) {
00413     if (gwenhywfar_gui->getPasswordFn)
00414       return gwenhywfar_gui->getPasswordFn(gwenhywfar_gui,
00415                                            flags,
00416                                            token,
00417                                            title,
00418                                            text,
00419                                            buffer,
00420                                            minLen,
00421                                            maxLen,
00422                                            guiid);
00423     else
00424       return gwenhywfar_gui->inputBoxFn(gwenhywfar_gui,
00425                                         flags,
00426                                         title,
00427                                         text,
00428                                         buffer,
00429                                         minLen,
00430                                         maxLen,
00431                                         guiid);
00432   }
00433   return GWEN_ERROR_NOT_IMPLEMENTED;
00434 }
00435 
00436 
00437 
00438 int GWEN_Gui_SetPasswordStatus(const char *token,
00439                                const char *pin,
00440                                GWEN_GUI_PASSWORD_STATUS status,
00441                                uint32_t guiid) {
00442   if (gwenhywfar_gui && gwenhywfar_gui->setPasswordStatusFn)
00443     return gwenhywfar_gui->setPasswordStatusFn(gwenhywfar_gui,
00444                                                token, pin, status, guiid);
00445   return GWEN_ERROR_NOT_IMPLEMENTED;
00446 }
00447 
00448 
00449 
00450 int GWEN_Gui_LogHook(const char *logDomain,
00451                      GWEN_LOGGER_LEVEL priority, const char *s) {
00452   if (gwenhywfar_gui && gwenhywfar_gui->logHookFn)
00453     return gwenhywfar_gui->logHookFn(gwenhywfar_gui, logDomain, priority, s);
00454   else
00455     /* handle as usual */
00456     return 0;
00457 }
00458 
00459 
00460 
00461 int GWEN_Gui_WaitForSockets(GWEN_SOCKET_LIST2 *readSockets,
00462                             GWEN_SOCKET_LIST2 *writeSockets,
00463                             uint32_t guiid,
00464                             int msecs) {
00465   if (gwenhywfar_gui && gwenhywfar_gui->waitForSocketsFn)
00466     return gwenhywfar_gui->waitForSocketsFn(gwenhywfar_gui, readSockets, writeSockets, guiid, msecs);
00467   else {
00468     GWEN_SOCKETSET *rset;
00469     GWEN_SOCKETSET *wset;
00470     GWEN_SOCKET_LIST2_ITERATOR *sit;
00471 
00472     rset=GWEN_SocketSet_new();
00473     wset=GWEN_SocketSet_new();
00474 
00475     /* fill read socket set */
00476     sit=GWEN_Socket_List2_First(readSockets);
00477     if (sit) {
00478       GWEN_SOCKET *s;
00479 
00480       s=GWEN_Socket_List2Iterator_Data(sit);
00481       assert(s);
00482 
00483       while(s) {
00484         GWEN_SocketSet_AddSocket(rset, s);
00485         s=GWEN_Socket_List2Iterator_Next(sit);
00486       }
00487       GWEN_Socket_List2Iterator_free(sit);
00488     }
00489 
00490     /* fill write socket set */
00491     sit=GWEN_Socket_List2_First(writeSockets);
00492     if (sit) {
00493       GWEN_SOCKET *s;
00494 
00495       s=GWEN_Socket_List2Iterator_Data(sit);
00496       assert(s);
00497 
00498       while(s) {
00499         GWEN_SocketSet_AddSocket(wset, s);
00500         s=GWEN_Socket_List2Iterator_Next(sit);
00501       }
00502       GWEN_Socket_List2Iterator_free(sit);
00503     }
00504 
00505     if (GWEN_SocketSet_GetSocketCount(rset)==0 &&
00506         GWEN_SocketSet_GetSocketCount(wset)==0) {
00507       /* no sockets to wait for, sleep for a few ms to keep cpu load down */
00508       GWEN_SocketSet_free(wset);
00509       GWEN_SocketSet_free(rset);
00510 
00511       if (msecs) {
00512         /* only sleep if a timeout was given */
00513         DBG_DEBUG(GWEN_LOGDOMAIN, "Sleeping (no socket)");
00514         GWEN_Socket_Select(NULL, NULL, NULL, GWEN_GUI_CPU_TIMEOUT);
00515       }
00516       return GWEN_ERROR_TIMEOUT;
00517     }
00518     else {
00519       int rv;
00520 
00521       rv=GWEN_Socket_Select(rset, wset, NULL, msecs);
00522       GWEN_SocketSet_free(wset);
00523       GWEN_SocketSet_free(rset);
00524 
00525       return rv;
00526     }
00527   }
00528 }
00529 
00530 
00531 
00532 int GWEN_Gui_CheckCert(const GWEN_SSLCERTDESCR *cd, GWEN_IO_LAYER *io, uint32_t guiid) {
00533   if (gwenhywfar_gui && gwenhywfar_gui->checkCertFn)
00534     return gwenhywfar_gui->checkCertFn(gwenhywfar_gui, cd, io, guiid);
00535   else
00536     return GWEN_ERROR_NOT_IMPLEMENTED;
00537 }
00538 
00539 
00540 
00541 int GWEN_Gui_CheckCertBuiltIn(GWEN_GUI *gui,
00542                               const GWEN_SSLCERTDESCR *cd,
00543                               GWEN_IO_LAYER *io, uint32_t guiid) {
00544   int rv;
00545   int isError;
00546   const char *hash;
00547   const char *status;
00548   const char *ipAddr;
00549   const char *statusOn;
00550   const char *statusOff;
00551   char varName[128];
00552   char dbuffer1[32];
00553   char dbuffer2[32];
00554   char buffer[8192];
00555   const GWEN_TIME *ti;
00556   const char *unknown;
00557   const char *commonName;
00558   const char *organizationName;
00559   const char *organizationalUnitName;
00560   const char *countryName;
00561   const char *localityName;
00562   const char *stateOrProvinceName;
00563 
00564   char *msg=I18S(
00565     "The following certificate has been received:\n"
00566     "Name        : %s\n"
00567     "Organisation: %s\n"
00568     "Department  : %s\n"
00569     "Country     : %s\n"
00570     "City        : %s\n"
00571     "State       : %s\n"
00572     "Valid after : %s\n"
00573     "Valid until : %s\n"
00574     "Hash        : %s\n"
00575     "Status      : %s\n"
00576     "Do you wish to accept this certificate?"
00577 
00578     "<html>"
00579     " <p>"
00580     "  The following certificate has been received:"
00581     " </p>"
00582     " <table>"
00583     "  <tr><td>Name</td><td>%s</td></tr>"
00584     "  <tr><td>Organisation</td><td>%s</td></tr>"
00585     "  <tr><td>Department</td><td>%s</td></tr>"
00586     "  <tr><td>Country</td><td>%s</td></tr>"
00587     "  <tr><td>City</td><td>%s</td></tr>"
00588     "  <tr><td>State</td><td>%s</td></tr>"
00589     "  <tr><td>Valid after</td><td>%s</td></tr>"
00590     "  <tr><td>Valid until</td><td>%s</td></tr>"
00591     "  <tr><td>Hash</td><td>%s</td></tr>"
00592     "  <tr><td>Status</td><td>%s%s%s</td></tr>"
00593     " </table>"
00594     " <p>"
00595     "  Do you wish to accept this certificate?"
00596     " </p>"
00597     "</html>"
00598     );
00599 
00600   memset(dbuffer1, 0, sizeof(dbuffer1));
00601   memset(dbuffer2, 0, sizeof(dbuffer2));
00602   memset(varName, 0, sizeof(varName));
00603 
00604   isError=GWEN_SslCertDescr_GetIsError(cd);
00605 
00606   hash=GWEN_SslCertDescr_GetFingerPrint(cd);
00607   status=GWEN_SslCertDescr_GetStatusText(cd);
00608   ipAddr=GWEN_SslCertDescr_GetIpAddress(cd);
00609 
00610   ti=GWEN_SslCertDescr_GetNotBefore(cd);
00611   if (ti) {
00612     GWEN_BUFFER *tbuf;
00613 
00614     tbuf=GWEN_Buffer_new(0, 32, 0, 1);
00615     /* TRANSLATORS: This string is used as a template string to
00616        convert a given time into your local translated timeformat. The
00617        following characters are accepted in the template string: Y -
00618        digit of the year, M - digit of the month, D - digit of the day
00619        of month, h - digit of the hour, m - digit of the minute, s-
00620        digit of the second. All other characters are left unchanged. */
00621     if (GWEN_Time_toString(ti, I18N("YYYY/MM/DD hh:mm:ss"), tbuf)) {
00622       DBG_ERROR(GWEN_LOGDOMAIN,
00623                 "Could not convert beforeDate to string");
00624       abort();
00625     }
00626     strncpy(dbuffer1, GWEN_Buffer_GetStart(tbuf), sizeof(dbuffer1)-1);
00627     GWEN_Buffer_free(tbuf);
00628   }
00629 
00630   ti=GWEN_SslCertDescr_GetNotAfter(cd);
00631   if (ti) {
00632     GWEN_BUFFER *tbuf;
00633 
00634     tbuf=GWEN_Buffer_new(0, 32, 0, 1);
00635     if (GWEN_Time_toString(ti, I18N("YYYY/MM/DD hh:mm:ss"), tbuf)) {
00636       DBG_ERROR(GWEN_LOGDOMAIN,
00637                 "Could not convert untilDate to string");
00638       abort();
00639     }
00640     strncpy(dbuffer2, GWEN_Buffer_GetStart(tbuf), sizeof(dbuffer2)-1);
00641     GWEN_Buffer_free(tbuf);
00642   }
00643 
00644   if (isError) {
00645     statusOn="<font color=red>";
00646     statusOff="</font>";
00647   }
00648   else {
00649     statusOn="<font color=green>";
00650     statusOff="</font>";
00651   }
00652 
00653   unknown=I18N("unknown");
00654   commonName=GWEN_SslCertDescr_GetCommonName(cd);
00655   if (!commonName)
00656     commonName=unknown;
00657   organizationName=GWEN_SslCertDescr_GetOrganizationName(cd);
00658   if (!organizationName)
00659     organizationName=unknown;
00660   organizationalUnitName=GWEN_SslCertDescr_GetOrganizationalUnitName(cd);
00661   if (!organizationalUnitName)
00662     organizationalUnitName=unknown;
00663   countryName=GWEN_SslCertDescr_GetCountryName(cd);
00664   if (!countryName)
00665     countryName=unknown;
00666   localityName=GWEN_SslCertDescr_GetLocalityName(cd);
00667   if (!localityName)
00668     localityName=unknown;
00669   stateOrProvinceName=GWEN_SslCertDescr_GetStateOrProvinceName(cd);
00670   if (!stateOrProvinceName)
00671     stateOrProvinceName=unknown;
00672   if (!status)
00673     status=unknown;
00674 
00675   snprintf(buffer, sizeof(buffer)-1,
00676            I18N(msg),
00677            commonName,
00678            organizationName,
00679            organizationalUnitName,
00680            countryName,
00681            localityName,
00682            stateOrProvinceName,
00683            dbuffer1, dbuffer2,
00684            hash,
00685            status,
00686            /* the same again for HTML */
00687            commonName,
00688            organizationName,
00689            organizationalUnitName,
00690            countryName,
00691            localityName,
00692            stateOrProvinceName,
00693            dbuffer1, dbuffer2,
00694            hash,
00695            statusOn,
00696            status,
00697            statusOff
00698           );
00699 
00700   rv=GWEN_Gui_MessageBox(GWEN_GUI_MSG_FLAGS_TYPE_WARN |
00701                          GWEN_GUI_MSG_FLAGS_CONFIRM_B1 |
00702                          GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS,
00703                          I18N("Certificate Received"),
00704                          buffer,
00705                          I18N("Yes"), I18N("No"), 0, guiid);
00706   if (rv==1) {
00707     return 0;
00708   }
00709   else {
00710     DBG_NOTICE(GWEN_LOGDOMAIN, "User rejected certificate");
00711 
00712     return GWEN_ERROR_SSL_SECURITY;
00713   }
00714 }
00715 
00716 
00717 
00718 int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text,
00719                                      unsigned char *buffer,
00720                                      unsigned int bufLength) {
00721   if (gwenhywfar_gui && gwenhywfar_gui->keyDataFromTextOpenSslFn)
00722     return gwenhywfar_gui->keyDataFromTextOpenSslFn(gwenhywfar_gui,
00723                                                     text,
00724                                                     buffer,
00725                                                     bufLength);
00726   return GWEN_ERROR_NOT_IMPLEMENTED;
00727 }
00728 
00729 
00730 
00731 
00732 
00733 
00734 
00735 
00736 
00737 
00738 
00739 
00740 
00741 
00742 
00743 

Generated on Fri Apr 11 01:53:46 2008 for gwenhywfar by  doxygen 1.5.5