/[winpt]/trunk/Src/wptMAPI.cpp
ViewVC logotype

Diff of /trunk/Src/wptMAPI.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 327 by twoaday, Fri May 25 14:53:02 2007 UTC revision 328 by twoaday, Fri Sep 25 16:07:38 2009 UTC
# Line 1  Line 1 
1  /* wptMAPI.cpp - MAPI interface for sending keys.  /* wptMAPI.cpp - MAPI interface for sending keys.
2   *      Copyright (C) 2003-2006 Timo Schulz   *      Copyright (C) 2003-2008 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 12  Line 12 
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
  *  
  * You should have received a copy of the GNU General Public License  
  * along with WinPT; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  
15   */   */
16  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
17  #include <config.h>  #include <config.h>
# Line 32  Line 28 
28  #include "wptGPG.h"  #include "wptGPG.h"
29  #include "wptVersion.h"  #include "wptVersion.h"
30  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
31    #include "wptKeylist.h"
32  #include "wptKeyManager.h"  #include "wptKeyManager.h"
33    
34    
# Line 72  struct mapi_err_s { Line 69  struct mapi_err_s {
69  const char*  const char*
70  mapi_strerror (int err)  mapi_strerror (int err)
71  {  {
72      int i;      for (int i=0; mapi_errors[i].msg; i++) {
   
     for (i=0; mapi_errors[i].msg; i++) {  
73          if (err == mapi_errors[i].err_no)          if (err == mapi_errors[i].err_no)
74              return mapi_errors[i].msg;              return mapi_errors[i].msg;
75      }      }
# Line 96  mapi_init (void) Line 91  mapi_init (void)
91    
92      mapi_logon = load_one_fnc (LPMAPILOGON, hlib, "MAPILogon");      mapi_logon = load_one_fnc (LPMAPILOGON, hlib, "MAPILogon");
93      mapi_logoff = load_one_fnc (LPMAPILOGOFF, hlib, "MAPILogoff");      mapi_logoff = load_one_fnc (LPMAPILOGOFF, hlib, "MAPILogoff");
94      mapi_send_documents = load_one_fnc (LPMAPISENDDOCUMENTS, hlib, "MAPISendDocuments");      mapi_send_documents = load_one_fnc (LPMAPISENDDOCUMENTS, hlib,
95                                            "MAPISendDocuments");
96      mapi_send_mail = load_one_fnc (LPMAPISENDMAIL, hlib, "MAPISendMail");      mapi_send_mail = load_one_fnc (LPMAPISENDMAIL, hlib, "MAPISendMail");
97      if (!mapi_logon || !mapi_logoff || !mapi_send_documents || !mapi_send_mail)      if (!mapi_logon || !mapi_logoff || !mapi_send_documents || !mapi_send_mail)
98          return -1;          return -1;
# Line 123  int Line 119  int
119  mapi_send_ascfile (char *ascfile)  mapi_send_ascfile (char *ascfile)
120  {  {
121      LHANDLE hd;      LHANDLE hd;
122      int rc;      ULONG rc;
123    
124      if (!init)      if (!init)
125          return 0;          return 0;
# Line 133  mapi_send_ascfile (char *ascfile) Line 129  mapi_send_ascfile (char *ascfile)
129          MessageBox (NULL, mapi_strerror (rc), _("MAPI Login failed"), MB_WARN);          MessageBox (NULL, mapi_strerror (rc), _("MAPI Login failed"), MB_WARN);
130          goto fail;          goto fail;
131      }      }
132      rc = mapi_send_documents (0, ";", ascfile, NULL, 0);      rc = mapi_send_documents (0, ";", ascfile, NULL, 0);    
133      if (rc == MAPI_E_USER_ABORT)      if (rc == MAPI_E_USER_ABORT)
134          rc = SUCCESS_SUCCESS;          rc = SUCCESS_SUCCESS;
135      if (rc != SUCCESS_SUCCESS)      if (rc != SUCCESS_SUCCESS)
136          MessageBox (NULL, _("Could not send mail."), "MAPI", MB_ICONERROR|MB_OK);          MessageBox (NULL, _("Could not send mail."), ascfile, MB_ICONERROR|MB_OK);
137    
138  fail:  fail:
139      mapi_logoff (hd, 0, 0, 0);      mapi_logoff (hd, 0, 0, 0);
# Line 161  free_recip_tab (MapiRecipDesc *recip, DW Line 157  free_recip_tab (MapiRecipDesc *recip, DW
157  {  {
158      DWORD i;      DWORD i;
159    
160      if (!recip)      if (!recip || !n)
         return;  
     if (!n)  
161          return;          return;
162      for (i=0; i < n; i++)      for (i=0; i < n; i++)
163          safe_free (recip[i].lpszName);          safe_free (recip[i].lpszName);
# Line 198  mapi_send_pubkey_ext (winpt_key_t key, c Line 192  mapi_send_pubkey_ext (winpt_key_t key, c
192      MapiFileDesc *attch;      MapiFileDesc *attch;
193      char *p, *kinf;      char *p, *kinf;
194      const char *s;      const char *s;
195      int rc;      ULONG rc;
196    
197      if (!init)      if (!init)
198          return 0;          return 0;
# Line 210  mapi_send_pubkey_ext (winpt_key_t key, c Line 204  mapi_send_pubkey_ext (winpt_key_t key, c
204      }      }
205    
206      msg = (MapiMessage *)calloc (1, sizeof *msg);      msg = (MapiMessage *)calloc (1, sizeof *msg);
207      if (!msg)      msg->lpszSubject = strdup (_("OpenPGP Public Key"));
208          BUG (0);  
209      p = msg->lpszSubject = strdup ("OpenPGP Public Key");      s = _("Attached is this OpenPGP public key:\n%s\n\n"
210      if (!p)            "Import this key via the clipboard or the Key Manager to\n"
211          BUG (0);            "exchange encrypted mails with the key holder and to be able\n"
212              "to verify its signatures.\n"
213      s = "Attached is this OpenPGP public key:\n%s\n\n"            "\n"
214          "Import this key via the clipboard or the Key Manager to\n"            "If you don't have WinPT, you can download it at http://winpt.gnupt.de");
         "exchange encrypted mails with the key holder and to be able\n"  
         "to verify its signatures.\n"  
         "\n"  
         "If you don't have WinPT, you can download it at http://www.winpt.eu";  
215      kinf = km_key_get_info (key, 0);      kinf = km_key_get_info (key, 0);
216      p = (char*)malloc (strlen (s) + strlen (kinf) + 2);      p = (char*)malloc (strlen (s) + strlen (kinf) + 2);
217      sprintf (p, s, kinf);      sprintf (p, s, kinf);
218      free_if_alloc (kinf);      free_if_alloc (kinf);
219    
220      p = msg->lpszNoteText = p;      msg->lpszNoteText = p;
     if (!p)  
         BUG (0);  
   
221      /* If the key was signed, we assume it shall be sent back to the owner. */      /* If the key was signed, we assume it shall be sent back to the owner. */
222      if (flags) {      if (flags) {
223          recip = (MapiRecipDesc *)calloc (1, sizeof *recip);          recip = (MapiRecipDesc *)calloc (1, sizeof *recip);
         if (!recip)  
             BUG (0);  
224          recip[0].ulRecipClass = MAPI_TO;          recip[0].ulRecipClass = MAPI_TO;
225          p = recip[0].lpszName = strdup (key->ext->uids->uid);          recip[0].lpszName = strdup (key->ext->uids->uid);
         if (!p)      
             BUG (0);  
226          msg->lpRecips = recip;          msg->lpRecips = recip;
227          msg->nRecipCount = 1;          msg->nRecipCount = 1;
228      }      }
# Line 250  mapi_send_pubkey_ext (winpt_key_t key, c Line 233  mapi_send_pubkey_ext (winpt_key_t key, c
233    
234      msg->nFileCount = 1;      msg->nFileCount = 1;
235      attch = (MapiFileDesc *)calloc (1, sizeof *attch);      attch = (MapiFileDesc *)calloc (1, sizeof *attch);
     if (!attch)  
         BUG (0);  
236      attch[0].lpszFileName = strdup (keyfile);      attch[0].lpszFileName = strdup (keyfile);
237      attch[0].lpszPathName = strdup (keyfile);      attch[0].lpszPathName = strdup (keyfile);
238      msg->lpFiles = attch;      msg->lpFiles = attch;

Legend:
Removed from v.327  
changed lines
  Added in v.328

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26