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

Diff of /trunk/Src/wptSigList.cpp

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

revision 139 by twoaday, Wed Jan 11 12:19:41 2006 UTC revision 271 by twoaday, Sun Nov 5 08:57:45 2006 UTC
# Line 26  Line 26 
26  #include <windows.h>  #include <windows.h>
27  #include <time.h>  #include <time.h>
28    
29    #include "resource.h"
30  #include "wptGPG.h"  #include "wptGPG.h"
31  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
32  #include "wptKeylist.h"  #include "wptKeylist.h"
33  #include "wptNLS.h"  #include "wptNLS.h"
 #include "wptUTF8.h"  
34  #include "wptErrors.h"  #include "wptErrors.h"
35  #include "wptTypes.h"  #include "wptTypes.h"
36  #include "wptW32API.h"  #include "wptW32API.h"
37    #include "wptVersion.h"
38    #include "wptContext.h"
39    
40    
41  /* Is the given signature an user-id signature? */  /* Is the given signature an user-id signature? */
# Line 43  Line 45 
45  /* Create a signature list control in @lv with the parent window  /* Create a signature list control in @lv with the parent window
46     given in @ctrl.     given in @ctrl.
47     Return value: 0 on success. */     Return value: 0 on success. */
48  static int  static void
49  siglist_build (listview_ctrl_t * lv, HWND ctrl)  siglist_build (listview_ctrl_t *lv, HWND ctrl)
50  {  {
51      struct listview_ctrl_s *c;      struct listview_ctrl_s *c;
52      struct listview_column_s implist[] = {      struct listview_column_s implist[] = {
# Line 56  siglist_build (listview_ctrl_t * lv, HWN Line 58  siglist_build (listview_ctrl_t * lv, HWN
58          {5,  68, (char *)_("Expiration")},          {5,  68, (char *)_("Expiration")},
59          {6,  56, (char *)_("Algorithm")},          {6,  56, (char *)_("Algorithm")},
60          {0,   0, NULL}          {0,   0, NULL}
61      };        };
62      int j, rc = 0;      int j;
63        
64      rc = listview_new (&c);      listview_new (&c, ctrl);
     if (rc)  
         return rc;  
     c->ctrl = ctrl;  
65      for  (j=0; implist[j].fieldname != NULL; j++)      for  (j=0; implist[j].fieldname != NULL; j++)
66          listview_add_column (c, &implist[j]);          listview_add_column (c, &implist[j]);
67      listview_set_ext_style (c);      listview_set_ext_style (c);
68        listview_del_all_items (c);
69      *lv = c;      *lv = c;
     return 0;  
70  }  }
71    
72    
73  /* Delete the signature control in @lv. */  /* Delete the signature control in @lv. */
74  void  void
75  siglist_delete( listview_ctrl_t lv )  siglist_delete (listview_ctrl_t lv)
76  {  {
77      if (lv) {      if (lv) {
78          listview_release (lv);          listview_release (lv);
# Line 83  siglist_delete( listview_ctrl_t lv ) Line 82  siglist_delete( listview_ctrl_t lv )
82    
83  /* Indent the string in @old with the level @ilvl.  /* Indent the string in @old with the level @ilvl.
84      Return value: indented string. */      Return value: indented string. */
85  static char *  static char*
86  indent_string (const char * old, int ilvl)  indent_string (const char *old, int ilvl)
87  {  {
88      char * p;      char *p;
89      int i;      int i;
90    
91      p = new char[strlen (old) + 1 + ilvl];      p = new char[strlen (old) + 1 + ilvl];
# Line 119  add_keysig_item (listview_ctrl_t ctx, in Line 118  add_keysig_item (listview_ctrl_t ctx, in
118     control @lv.     control @lv.
119     Return value: 0 on success. */     Return value: 0 on success. */
120  static int  static int
121  siglist_add_key (listview_ctrl_t lv, gpgme_user_id_t uid,  siglist_add_key (listview_ctrl_t lv, struct native_uid_s *uid,
122                   gpgme_key_sig_t ks, int pos)                   gpgme_key_sig_t ks, int pos)
123  {  {
124      gpgme_key_t key=NULL;      struct winpt_key_s key;    
     char t[128];  
125      const char *attr;      const char *attr;
126      const char *s;      const char *s;
127      int key_attr, no_uid = 0;      char t[128];
128        int no_uid = 0;
129      int rc = 0;      int rc = 0;
130    
131      if (ks && !IS_UID_CERT (ks->sig_class))      if (ks && !IS_UID_CERT (ks->sig_class))
# Line 138  siglist_add_key (listview_ctrl_t lv, gpg Line 137  siglist_add_key (listview_ctrl_t lv, gpg
137    
138      attr = NULL;      attr = NULL;
139      if (!uid) {      if (!uid) {
140          get_pubkey (ks->keyid, &key);          memset (&key, 0, sizeof (key));
141          if (key)          winpt_get_pubkey (ks->keyid, &key);
142              attr = key->uids->uid;          if (key.ext != NULL)
143                attr = key.ext->uids->uid;
144      }      }
145      else      else
146          attr = uid->uid;          attr = uid->uid;
147      if (attr && strlen (attr)) {      if (attr && strlen (attr)) {
148          char *uid_utf8 = utf8_to_wincp (attr, strlen (attr));          char *p = uid? m_strdup (attr) : indent_string (attr, 2);
149          char *p = uid? m_strdup (uid_utf8) : indent_string (uid_utf8, 2);          listview_add_sub_item (lv, pos, SL_COL_UID, p);
         listview_add_sub_item (lv, pos, 0, p);  
         free (uid_utf8);  
150          free_if_alloc (p);          free_if_alloc (p);
151      }      }
152      else {      else {
153          listview_add_sub_item (lv, pos, 0, _("  user ID not found"));          listview_add_sub_item (lv, pos, SL_COL_UID, _("  user ID not found"));
154          no_uid = 1;          no_uid = 1;
155      }      }
156    
157        /* Return immediately for root items. */
158      if (uid)      if (uid)
159          return 0;          return 0;
160    
# Line 167  siglist_add_key (listview_ctrl_t lv, gpg Line 166  siglist_add_key (listview_ctrl_t lv, gpg
166      }      }
167      if (no_uid)      if (no_uid)
168          s = "NOKEY";          s = "NOKEY";
169      listview_add_sub_item (lv, pos, 1, s);      listview_add_sub_item (lv, pos, SL_COL_VALID, s);
170    
171      switch (ks->sig_class) {      switch (ks->sig_class) {
172      case 0x10: strcpy (t, " "); break;      case 0x10: strcpy (t, " "); break;
# Line 175  siglist_add_key (listview_ctrl_t lv, gpg Line 174  siglist_add_key (listview_ctrl_t lv, gpg
174      case 0x12: strcpy (t, "2"); break;      case 0x12: strcpy (t, "2"); break;
175      case 0x13: strcpy (t, "3"); break;      case 0x13: strcpy (t, "3"); break;
176      }      }
177            
178      strcat (t, " ");      strcat (t, " ");
179      if (!ks->exportable)      if (!ks->exportable)
180          strcat (t, "L");          strcat (t, "L");
181      /*if (key_attr & GPGME_SIGF_NREV)      /* XXX: if gpgme supports non-revocable status, add 'R' */
182          strcat (t, "R");*/      listview_add_sub_item (lv, pos, SL_COL_CLASS, t);
183      listview_add_sub_item (lv, pos, 2, t);  
184        s = get_key_created (ks->timestamp);
185      key_attr = ks->timestamp;      listview_add_sub_item (lv, pos, SL_COL_CREATE, s);
186      if( key_attr ) {  
187          s = get_key_created (key_attr);      if (ks->keyid && strlen (ks->keyid) == 16) {
188          listview_add_sub_item (lv, pos, 3, s);          _snprintf (t, DIM (t) -1, "0x%s", ks->keyid + 8);
189      }          listview_add_sub_item (lv, pos, SL_COL_KEYID, t);
       
     attr = ks->keyid;  
     if (attr && strlen (attr) == 16) {  
         _snprintf (t, sizeof (t) -1, "0x%s", attr + 8);  
         listview_add_sub_item (lv, pos, 4, t);  
190      }      }
191    
192      key_attr = ks->expires;      if (ks->expires > 0) {
193      if (key_attr) {          s = get_key_created (ks->expires);
194          s = get_key_created (key_attr);          listview_add_sub_item (lv, pos, SL_COL_EXPIRE, s);
         listview_add_sub_item (lv, pos, 5, s);  
195      }      }
196    
197      attr = get_key_pubalgo (ks->pubkey_algo);      attr = get_key_pubalgo (ks->pubkey_algo);
# Line 215  siglist_add_key (listview_ctrl_t lv, gpg Line 208  siglist_add_key (listview_ctrl_t lv, gpg
208  listview_ctrl_t  listview_ctrl_t
209  siglist_load (HWND ctrl, const char *keyid)  siglist_load (HWND ctrl, const char *keyid)
210  {      {    
     gpgme_key_t key;  
     gpgme_user_id_t u;  
211      gpgme_key_sig_t s;      gpgme_key_sig_t s;
212        struct native_uid_s *u;
213        winpt_key_s key;
214      listview_ctrl_t lv;      listview_ctrl_t lv;
215      int pos = 0;      int pos = 0;
216      int rc;      int rc = 0;
217    
218      if (siglist_build (&lv, ctrl))      siglist_build (&lv, ctrl);
219          BUG (NULL);      memset (&key, 0, sizeof (key));
220      rc = get_pubkey(keyid, &key);      if (winpt_get_pubkey (keyid, &key))
     if (rc)  
221          BUG (NULL);          BUG (NULL);
222    
223      for (u=key->uids; u; u = u->next) {      for (u=key.ext->uids; u; u = u->next) {
224          siglist_add_key (lv, u, NULL, pos++);          siglist_add_key (lv, u, NULL, pos++);
225          for (s = u->signatures; s; s = s->next) {          for (s = u->signatures; s; s = s->next) {
226              if (!IS_UID_CERT (s->sig_class))              if (!IS_UID_CERT (s->sig_class))

Legend:
Removed from v.139  
changed lines
  Added in v.271

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26