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 *GWEN_Gui_GetGui() {
00093   return gwenhywfar_gui;
00094 }
00095 
00096 
00097 
00098 GWEN_GUI_MESSAGEBOX_FN GWEN_Gui_SetMessageBoxFn(GWEN_GUI *gui,
00099                                                 GWEN_GUI_MESSAGEBOX_FN f){
00100   GWEN_GUI_MESSAGEBOX_FN of;
00101 
00102   assert(gui);
00103   of=gui->messageBoxFn;
00104   gui->messageBoxFn=f;
00105   return of;
00106 }
00107 
00108 
00109 
00110 GWEN_GUI_INPUTBOX_FN GWEN_Gui_SetInputBoxFn(GWEN_GUI *gui,
00111                                             GWEN_GUI_INPUTBOX_FN f){
00112   GWEN_GUI_INPUTBOX_FN of;
00113 
00114   assert(gui);
00115   of=gui->inputBoxFn;
00116   gui->inputBoxFn=f;
00117   return of;
00118 }
00119 
00120 
00121 
00122 GWEN_GUI_SHOWBOX_FN GWEN_Gui_SetShowBoxFn(GWEN_GUI *gui,
00123                                           GWEN_GUI_SHOWBOX_FN f){
00124   GWEN_GUI_SHOWBOX_FN of;
00125 
00126   assert(gui);
00127   of=gui->showBoxFn;
00128   gui->showBoxFn=f;
00129   return of;
00130 }
00131 
00132 
00133 
00134 GWEN_GUI_HIDEBOX_FN GWEN_Gui_SetHideBoxFn(GWEN_GUI *gui,
00135                                           GWEN_GUI_HIDEBOX_FN f){
00136   GWEN_GUI_HIDEBOX_FN of;
00137 
00138   assert(gui);
00139   of=gui->hideBoxFn;
00140   gui->hideBoxFn=f;
00141   return of;
00142 }
00143 
00144 
00145 
00146 GWEN_GUI_PROGRESS_START_FN
00147 GWEN_Gui_SetProgressStartFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_START_FN f){
00148   GWEN_GUI_PROGRESS_START_FN of;
00149 
00150   assert(gui);
00151   of=gui->progressStartFn;
00152   gui->progressStartFn=f;
00153   return of;
00154 }
00155 
00156 
00157 
00158 GWEN_GUI_PROGRESS_ADVANCE_FN
00159 GWEN_Gui_SetProgressAdvanceFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_ADVANCE_FN f){
00160   GWEN_GUI_PROGRESS_ADVANCE_FN of;
00161 
00162   assert(gui);
00163   of=gui->progressAdvanceFn;
00164   gui->progressAdvanceFn=f;
00165   return of;
00166 }
00167 
00168 
00169 
00170 GWEN_GUI_PROGRESS_LOG_FN
00171 GWEN_Gui_SetProgressLogFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_LOG_FN f){
00172   GWEN_GUI_PROGRESS_LOG_FN of;
00173 
00174   assert(gui);
00175   of=gui->progressLogFn;
00176   gui->progressLogFn=f;
00177   return of;
00178 }
00179 
00180 
00181 
00182 GWEN_GUI_PROGRESS_END_FN
00183 GWEN_Gui_SetProgressEndFn(GWEN_GUI *gui, GWEN_GUI_PROGRESS_END_FN f){
00184   GWEN_GUI_PROGRESS_END_FN of;
00185 
00186   assert(gui);
00187   of=gui->progressEndFn;
00188   gui->progressEndFn=f;
00189   return of;
00190 }
00191 
00192 
00193 
00194 GWEN_GUI_PRINT_FN GWEN_Gui_SetPrintFn(GWEN_GUI *gui,
00195                                       GWEN_GUI_PRINT_FN f){
00196   GWEN_GUI_PRINT_FN of;
00197 
00198   assert(gui);
00199   of=gui->printFn;
00200   gui->printFn=f;
00201   return of;
00202 }
00203 
00204 
00205 
00206 GWEN_GUI_GETPASSWORD_FN GWEN_Gui_SetGetPasswordFn(GWEN_GUI *gui,
00207                                                   GWEN_GUI_GETPASSWORD_FN f) {
00208   GWEN_GUI_GETPASSWORD_FN of;
00209 
00210   assert(gui);
00211   of=gui->getPasswordFn;
00212   gui->getPasswordFn=f;
00213   return of;
00214 }
00215 
00216 
00217 
00218 GWEN_GUI_SETPASSWORDSTATUS_FN
00219 GWEN_Gui_SetSetPasswordStatusFn(GWEN_GUI *gui,
00220                                 GWEN_GUI_SETPASSWORDSTATUS_FN f) {
00221   GWEN_GUI_SETPASSWORDSTATUS_FN of;
00222 
00223   assert(gui);
00224   of=gui->setPasswordStatusFn;
00225   gui->setPasswordStatusFn=f;
00226   return of;
00227 }
00228 
00229 
00230 
00231 GWEN_GUI_LOG_HOOK_FN GWEN_Gui_SetLogHookFn(GWEN_GUI *gui,
00232                                            GWEN_GUI_LOG_HOOK_FN f) {
00233   GWEN_GUI_LOG_HOOK_FN of;
00234 
00235   assert(gui);
00236   of=gui->logHookFn;
00237   gui->logHookFn=f;
00238 
00239   return of;
00240 }
00241 
00242 
00243 
00244 GWEN_GUI_WAITFORSOCKETS_FN GWEN_Gui_SetWaitForSocketsFn(GWEN_GUI *gui,
00245                                                         GWEN_GUI_WAITFORSOCKETS_FN f) {
00246   GWEN_GUI_WAITFORSOCKETS_FN of;
00247 
00248   assert(gui);
00249   of=gui->waitForSocketsFn;
00250   gui->waitForSocketsFn=f;
00251 
00252   return of;
00253 }
00254 
00255 
00256 
00257 GWEN_GUI_CHECKCERT_FN GWEN_Gui_SetCheckCertFn(GWEN_GUI *gui, GWEN_GUI_CHECKCERT_FN f) {
00258   GWEN_GUI_CHECKCERT_FN of;
00259 
00260   assert(gui);
00261   of=gui->checkCertFn;
00262   gui->checkCertFn=f;
00263 
00264   return of;
00265 }
00266 
00267 
00268 
00269 GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN
00270 GWEN_Gui_SetKeyDataFromTextOpenSslFn(GWEN_GUI *gui,
00271                                      GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN f) {
00272   GWEN_GUI_KEYDATAFROMTEXT_OPENSSL_FN of;
00273 
00274   assert(gui);
00275   of=gui->keyDataFromTextOpenSslFn;
00276   gui->keyDataFromTextOpenSslFn=f;
00277 
00278   return of;
00279 
00280 }
00281 
00282 
00283 
00284 
00285 
00286 
00287 
00288 int GWEN_Gui_MessageBox(uint32_t flags,
00289                         const char *title,
00290                         const char *text,
00291                         const char *b1,
00292                         const char *b2,
00293                         const char *b3,
00294                         uint32_t guiid) {
00295   if (gwenhywfar_gui && gwenhywfar_gui->messageBoxFn)
00296     return gwenhywfar_gui->messageBoxFn(gwenhywfar_gui,
00297                                         flags,
00298                                         title,
00299                                         text,
00300                                         b1, b2, b3, guiid);
00301   return GWEN_ERROR_NOT_IMPLEMENTED;
00302 }
00303 
00304 
00305 
00306 int GWEN_Gui_InputBox(uint32_t flags,
00307                       const char *title,
00308                       const char *text,
00309                       char *buffer,
00310                       int minLen,
00311                       int maxLen,
00312                       uint32_t guiid) {
00313   if (gwenhywfar_gui && gwenhywfar_gui->inputBoxFn)
00314     return gwenhywfar_gui->inputBoxFn(gwenhywfar_gui,
00315                                       flags,
00316                                       title,
00317                                       text,
00318                                       buffer,
00319                                       minLen, maxLen, guiid);
00320   return GWEN_ERROR_NOT_IMPLEMENTED;
00321 }
00322 
00323 
00324 
00325 uint32_t GWEN_Gui_ShowBox(uint32_t flags,
00326                           const char *title,
00327                           const char *text,
00328                           uint32_t guiid) {
00329   if (gwenhywfar_gui && gwenhywfar_gui->showBoxFn)
00330     return gwenhywfar_gui->showBoxFn(gwenhywfar_gui,
00331                                      flags,
00332                                      title,
00333                                      text,
00334                                      guiid);
00335   return 0;
00336 }
00337 
00338 
00339 
00340 void GWEN_Gui_HideBox(uint32_t id) {
00341   if (gwenhywfar_gui && gwenhywfar_gui->hideBoxFn)
00342     return gwenhywfar_gui->hideBoxFn(gwenhywfar_gui, id);
00343 }
00344 
00345 
00346 
00347 uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags,
00348                                 const char *title,
00349                                 const char *text,
00350                                 uint64_t total,
00351                                 uint32_t guiid) {
00352   if (gwenhywfar_gui && gwenhywfar_gui->progressStartFn)
00353     return gwenhywfar_gui->progressStartFn(gwenhywfar_gui,
00354                                            progressFlags,
00355                                            title,
00356                                            text,
00357                                            total,
00358                                            guiid);
00359   return 0;
00360 }
00361 
00362 
00363 
00364 int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress) {
00365   if (gwenhywfar_gui && gwenhywfar_gui->progressAdvanceFn)
00366     return gwenhywfar_gui->progressAdvanceFn(gwenhywfar_gui,
00367                                              id,
00368                                              progress);
00369   return 0;
00370 }
00371 
00372 
00373 
00374 int GWEN_Gui_ProgressLog(uint32_t id,
00375                          GWEN_LOGGER_LEVEL level,
00376                          const char *text) {
00377   if (gwenhywfar_gui && gwenhywfar_gui->progressLogFn)
00378     return gwenhywfar_gui->progressLogFn(gwenhywfar_gui,
00379                                          id, level, text);
00380   return 0;
00381 }
00382 
00383 
00384 
00385 int GWEN_Gui_ProgressEnd(uint32_t id) {
00386   if (gwenhywfar_gui && gwenhywfar_gui->progressEndFn)
00387     return gwenhywfar_gui->progressEndFn(gwenhywfar_gui, id);
00388   return GWEN_ERROR_NOT_IMPLEMENTED;
00389 }
00390 
00391 
00392 
00393 int GWEN_Gui_Print(const char *docTitle,
00394                    const char *docType,
00395                    const char *descr,
00396                    const char *text,
00397                    uint32_t guiid) {
00398   if (gwenhywfar_gui && gwenhywfar_gui->printFn)
00399     return gwenhywfar_gui->printFn(gwenhywfar_gui,
00400                                    docTitle,
00401                                    docType,
00402                                    descr,
00403                                    text,
00404                                    guiid);
00405   return GWEN_ERROR_NOT_IMPLEMENTED;
00406 }
00407 
00408 
00409 
00410 int GWEN_Gui_GetPassword(uint32_t flags,
00411                          const char *token,
00412                          const char *title,
00413                          const char *text,
00414                          char *buffer,
00415                          int minLen,
00416                          int maxLen,
00417                          uint32_t guiid) {
00418   if (gwenhywfar_gui) {
00419     if (gwenhywfar_gui->getPasswordFn)
00420       return gwenhywfar_gui->getPasswordFn(gwenhywfar_gui,
00421                                            flags,
00422                                            token,
00423                                            title,
00424                                            text,
00425                                            buffer,
00426                                            minLen,
00427                                            maxLen,
00428                                            guiid);
00429     else
00430       return gwenhywfar_gui->inputBoxFn(gwenhywfar_gui,
00431                                         flags,
00432                                         title,
00433                                         text,
00434                                         buffer,
00435                                         minLen,
00436                                         maxLen,
00437                                         guiid);
00438   }
00439   return GWEN_ERROR_NOT_IMPLEMENTED;
00440 }
00441 
00442 
00443 
00444 int GWEN_Gui_SetPasswordStatus(const char *token,
00445                                const char *pin,
00446                                GWEN_GUI_PASSWORD_STATUS status,
00447                                uint32_t guiid) {
00448   if (gwenhywfar_gui && gwenhywfar_gui->setPasswordStatusFn)
00449     return gwenhywfar_gui->setPasswordStatusFn(gwenhywfar_gui,
00450                                                token, pin, status, guiid);
00451   return GWEN_ERROR_NOT_IMPLEMENTED;
00452 }
00453 
00454 
00455 
00456 int GWEN_Gui_LogHook(const char *logDomain,
00457                      GWEN_LOGGER_LEVEL priority, const char *s) {
00458   if (gwenhywfar_gui && gwenhywfar_gui->logHookFn) {
00459     if (priority>=GWEN_LoggerLevel_Debug &&
00460         logDomain &&
00461         strcasecmp(logDomain, "gwenhywfar")==0)
00462       /* don't send possibly sensitive data to the log function because
00463        * some application tend to store the messages indiscriminately.
00464        * In some cases sensitive information can be send to this function
00465        * which we don't want the application to store */
00466       return 0;
00467     else
00468       /* otherwise the log message seems to be uncritical, convey it */
00469       return gwenhywfar_gui->logHookFn(gwenhywfar_gui, logDomain, priority, s);
00470   }
00471   else
00472     /* handle as usual */
00473     return 0;
00474 }
00475 
00476 
00477 
00478 int GWEN_Gui_WaitForSockets(GWEN_SOCKET_LIST2 *readSockets,
00479                             GWEN_SOCKET_LIST2 *writeSockets,
00480                             uint32_t guiid,
00481                             int msecs) {
00482   if (gwenhywfar_gui && gwenhywfar_gui->waitForSocketsFn)
00483     return gwenhywfar_gui->waitForSocketsFn(gwenhywfar_gui, readSockets, writeSockets, guiid, msecs);
00484   else {
00485     GWEN_SOCKETSET *rset;
00486     GWEN_SOCKETSET *wset;
00487     GWEN_SOCKET_LIST2_ITERATOR *sit;
00488 
00489     rset=GWEN_SocketSet_new();
00490     wset=GWEN_SocketSet_new();
00491 
00492     /* fill read socket set */
00493     sit=GWEN_Socket_List2_First(readSockets);
00494     if (sit) {
00495       GWEN_SOCKET *s;
00496 
00497       s=GWEN_Socket_List2Iterator_Data(sit);
00498       assert(s);
00499 
00500       while(s) {
00501         GWEN_SocketSet_AddSocket(rset, s);
00502         s=GWEN_Socket_List2Iterator_Next(sit);
00503       }
00504       GWEN_Socket_List2Iterator_free(sit);
00505     }
00506 
00507     /* fill write socket set */
00508     sit=GWEN_Socket_List2_First(writeSockets);
00509     if (sit) {
00510       GWEN_SOCKET *s;
00511 
00512       s=GWEN_Socket_List2Iterator_Data(sit);
00513       assert(s);
00514 
00515       while(s) {
00516         GWEN_SocketSet_AddSocket(wset, s);
00517         s=GWEN_Socket_List2Iterator_Next(sit);
00518       }
00519       GWEN_Socket_List2Iterator_free(sit);
00520     }
00521 
00522     if (GWEN_SocketSet_GetSocketCount(rset)==0 &&
00523         GWEN_SocketSet_GetSocketCount(wset)==0) {
00524       /* no sockets to wait for, sleep for a few ms to keep cpu load down */
00525       GWEN_SocketSet_free(wset);
00526       GWEN_SocketSet_free(rset);
00527 
00528       if (msecs) {
00529         /* only sleep if a timeout was given */
00530         DBG_DEBUG(GWEN_LOGDOMAIN, "Sleeping (no socket)");
00531         GWEN_Socket_Select(NULL, NULL, NULL, GWEN_GUI_CPU_TIMEOUT);
00532       }
00533       return GWEN_ERROR_TIMEOUT;
00534     }
00535     else {
00536       int rv;
00537 
00538       rv=GWEN_Socket_Select(rset, wset, NULL, msecs);
00539       GWEN_SocketSet_free(wset);
00540       GWEN_SocketSet_free(rset);
00541 
00542       return rv;
00543     }
00544   }
00545 }
00546 
00547 
00548 
00549 int GWEN_Gui_CheckCert(const GWEN_SSLCERTDESCR *cd, GWEN_IO_LAYER *io, uint32_t guiid) {
00550   if (gwenhywfar_gui && gwenhywfar_gui->checkCertFn)
00551     return gwenhywfar_gui->checkCertFn(gwenhywfar_gui, cd, io, guiid);
00552   else
00553     return GWEN_ERROR_NOT_IMPLEMENTED;
00554 }
00555 
00556 
00557 
00558 int GWEN_Gui_CheckCertBuiltIn(GWEN_UNUSED GWEN_GUI *gui,
00559                               const GWEN_SSLCERTDESCR *cd,
00560                               GWEN_UNUSED GWEN_IO_LAYER *io, uint32_t guiid) {
00561   int rv;
00562   int isError;
00563   const char *hash;
00564   const char *status;
00565   const char *ipAddr;
00566   const char *statusOn;
00567   const char *statusOff;
00568   char varName[128];
00569   char dbuffer1[32];
00570   char dbuffer2[32];
00571   char buffer[8192];
00572   const GWEN_TIME *ti;
00573   const char *unknown;
00574   const char *commonName;
00575   const char *organizationName;
00576   const char *organizationalUnitName;
00577   const char *countryName;
00578   const char *localityName;
00579   const char *stateOrProvinceName;
00580 
00581   char *msg=I18S(
00582     "The following certificate has been received:\n"
00583     "Name        : %s\n"
00584     "Organisation: %s\n"
00585     "Department  : %s\n"
00586     "Country     : %s\n"
00587     "City        : %s\n"
00588     "State       : %s\n"
00589     "Valid after : %s\n"
00590     "Valid until : %s\n"
00591     "Hash        : %s\n"
00592     "Status      : %s\n"
00593     "Do you wish to accept this certificate?"
00594 
00595     "<html>"
00596     " <p>"
00597     "  The following certificate has been received:"
00598     " </p>"
00599     " <table>"
00600     "  <tr><td>Name</td><td>%s</td></tr>"
00601     "  <tr><td>Organisation</td><td>%s</td></tr>"
00602     "  <tr><td>Department</td><td>%s</td></tr>"
00603     "  <tr><td>Country</td><td>%s</td></tr>"
00604     "  <tr><td>City</td><td>%s</td></tr>"
00605     "  <tr><td>State</td><td>%s</td></tr>"
00606     "  <tr><td>Valid after</td><td>%s</td></tr>"
00607     "  <tr><td>Valid until</td><td>%s</td></tr>"
00608     "  <tr><td>Hash</td><td>%s</td></tr>"
00609     "  <tr><td>Status</td><td>%s%s%s</td></tr>"
00610     " </table>"
00611     " <p>"
00612     "  Do you wish to accept this certificate?"
00613     " </p>"
00614     "</html>"
00615     );
00616 
00617   memset(dbuffer1, 0, sizeof(dbuffer1));
00618   memset(dbuffer2, 0, sizeof(dbuffer2));
00619   memset(varName, 0, sizeof(varName));
00620 
00621   isError=GWEN_SslCertDescr_GetIsError(cd);
00622 
00623   hash=GWEN_SslCertDescr_GetFingerPrint(cd);
00624   status=GWEN_SslCertDescr_GetStatusText(cd);
00625   ipAddr=GWEN_SslCertDescr_GetIpAddress(cd);
00626 
00627   ti=GWEN_SslCertDescr_GetNotBefore(cd);
00628   if (ti) {
00629     GWEN_BUFFER *tbuf;
00630 
00631     tbuf=GWEN_Buffer_new(0, 32, 0, 1);
00632     /* TRANSLATORS: This string is used as a template string to
00633        convert a given time into your local translated timeformat. The
00634        following characters are accepted in the template string: Y -
00635        digit of the year, M - digit of the month, D - digit of the day
00636        of month, h - digit of the hour, m - digit of the minute, s-
00637        digit of the second. All other characters are left unchanged. */
00638     if (GWEN_Time_toString(ti, I18N("YYYY/MM/DD hh:mm:ss"), tbuf)) {
00639       DBG_ERROR(GWEN_LOGDOMAIN,
00640                 "Could not convert beforeDate to string");
00641       abort();
00642     }
00643     strncpy(dbuffer1, GWEN_Buffer_GetStart(tbuf), sizeof(dbuffer1)-1);
00644     GWEN_Buffer_free(tbuf);
00645   }
00646 
00647   ti=GWEN_SslCertDescr_GetNotAfter(cd);
00648   if (ti) {
00649     GWEN_BUFFER *tbuf;
00650 
00651     tbuf=GWEN_Buffer_new(0, 32, 0, 1);
00652     if (GWEN_Time_toString(ti, I18N("YYYY/MM/DD hh:mm:ss"), tbuf)) {
00653       DBG_ERROR(GWEN_LOGDOMAIN,
00654                 "Could not convert untilDate to string");
00655       abort();
00656     }
00657     strncpy(dbuffer2, GWEN_Buffer_GetStart(tbuf), sizeof(dbuffer2)-1);
00658     GWEN_Buffer_free(tbuf);
00659   }
00660 
00661   if (isError) {
00662     statusOn="<font color=red>";
00663     statusOff="</font>";
00664   }
00665   else {
00666     statusOn="<font color=green>";
00667     statusOff="</font>";
00668   }
00669 
00670   unknown=I18N("unknown");
00671   commonName=GWEN_SslCertDescr_GetCommonName(cd);
00672   if (!commonName)
00673     commonName=unknown;
00674   organizationName=GWEN_SslCertDescr_GetOrganizationName(cd);
00675   if (!organizationName)
00676     organizationName=unknown;
00677   organizationalUnitName=GWEN_SslCertDescr_GetOrganizationalUnitName(cd);
00678   if (!organizationalUnitName)
00679     organizationalUnitName=unknown;
00680   countryName=GWEN_SslCertDescr_GetCountryName(cd);
00681   if (!countryName)
00682     countryName=unknown;
00683   localityName=GWEN_SslCertDescr_GetLocalityName(cd);
00684   if (!localityName)
00685     localityName=unknown;
00686   stateOrProvinceName=GWEN_SslCertDescr_GetStateOrProvinceName(cd);
00687   if (!stateOrProvinceName)
00688     stateOrProvinceName=unknown;
00689   if (!status)
00690     status=unknown;
00691 
00692   snprintf(buffer, sizeof(buffer)-1,
00693            I18N(msg),
00694            commonName,
00695            organizationName,
00696            organizationalUnitName,
00697            countryName,
00698            localityName,
00699            stateOrProvinceName,
00700            dbuffer1, dbuffer2,
00701            hash,
00702            status,
00703            /* the same again for HTML */
00704            commonName,
00705            organizationName,
00706            organizationalUnitName,
00707            countryName,
00708            localityName,
00709            stateOrProvinceName,
00710            dbuffer1, dbuffer2,
00711            hash,
00712            statusOn,
00713            status,
00714            statusOff
00715           );
00716 
00717   rv=GWEN_Gui_MessageBox(GWEN_GUI_MSG_FLAGS_TYPE_WARN |
00718                          GWEN_GUI_MSG_FLAGS_CONFIRM_B1 |
00719                          GWEN_GUI_MSG_FLAGS_SEVERITY_DANGEROUS,
00720                          I18N("Certificate Received"),
00721                          buffer,
00722                          I18N("Yes"), I18N("No"), 0, guiid);
00723   if (rv==1) {
00724     return 0;
00725   }
00726   else {
00727     DBG_NOTICE(GWEN_LOGDOMAIN, "User rejected certificate");
00728 
00729     return GWEN_ERROR_SSL_SECURITY;
00730   }
00731 }
00732 
00733 
00734 
00735 int GWEN_Gui_KeyDataFromText_OpenSSL(const char *text,
00736                                      unsigned char *buffer,
00737                                      unsigned int bufLength) {
00738   if (gwenhywfar_gui && gwenhywfar_gui->keyDataFromTextOpenSslFn)
00739     return gwenhywfar_gui->keyDataFromTextOpenSslFn(gwenhywfar_gui,
00740                                                     text,
00741                                                     buffer,
00742                                                     bufLength);
00743   return GWEN_ERROR_NOT_IMPLEMENTED;
00744 }
00745 
00746 
00747 
00748 
00749 
00750 
00751 
00752 
00753 
00754 
00755 
00756 
00757 
00758 
00759 
00760 

doxygen