COM-30 COM-24: Refactorings
authorMarkus Schaber <markus@pep-security.net>
Wed, 05 Oct 2016 23:57:25 +0200
changeset 18051f843f18dd2
parent 179 4d7e5bf27a3b
child 181 db9b0b914e77
COM-30 COM-24: Refactorings
Fix spellings of members
CpEpEngine.cpp
pEpCOMServerAdapter.idl
pEp_utility.cpp
     1.1 --- a/CpEpEngine.cpp	Wed Oct 05 21:53:59 2016 +0200
     1.2 +++ b/CpEpEngine.cpp	Wed Oct 05 23:57:25 2016 +0200
     1.3 @@ -665,9 +665,9 @@
     1.4  	if (verbose_mode) {
     1.5  		stringstream ss;
     1.6  		ss << "TrustPersonalKey called with ";
     1.7 -		ss << utf8_string(ident->address);
     1.8 +		ss << utf8_string(ident->Address);
     1.9  		ss << L": ";
    1.10 -		ss << ident->commType;
    1.11 +		ss << ident->CommType;
    1.12  		verbose(ss.str());
    1.13  	}
    1.14  
    1.15 @@ -766,7 +766,7 @@
    1.16  	keysync_thread = NULL;
    1.17  	::unregister_sync_callbacks(keysync_session);
    1.18  	release(keysync_session);
    1.19 -    keysync_session == NULL;
    1.20 +    keysync_session = NULL;
    1.21  	keysync_abort_requested = false;
    1.22  }
    1.23  
     2.1 --- a/pEpCOMServerAdapter.idl	Wed Oct 05 21:53:59 2016 +0200
     2.2 +++ b/pEpCOMServerAdapter.idl	Wed Oct 05 23:57:25 2016 +0200
     2.3 @@ -114,12 +114,12 @@
     2.4      } pEpComType;
     2.5  
     2.6      [uuid(0CB90E62-8A6A-4CA0-99D7-481704051FF0)] struct pEpIdentity {
     2.7 -        BSTR address;
     2.8 -        BSTR fpr;
     2.9 -        BSTR userId;
    2.10 -        BSTR username;
    2.11 -        pEpComType commType;
    2.12 -        BSTR lang;
    2.13 +        BSTR Address;
    2.14 +        BSTR Fpr;
    2.15 +        BSTR UserId;
    2.16 +        BSTR UserName;
    2.17 +        pEpComType CommType;
    2.18 +        BSTR Lang;
    2.19      };
    2.20      
    2.21      // Keymanagement API
    2.22 @@ -185,35 +185,35 @@
    2.23      } pEpMsgDirection;
    2.24  
    2.25      [uuid(3A8A4F13-3402-4C4C-94AB-598D87869380)] struct StringPair {
    2.26 -        BSTR name;
    2.27 -        BSTR value;
    2.28 +        BSTR Name;
    2.29 +        BSTR Value;
    2.30      };
    2.31  
    2.32      [uuid(61DA7AD4-192E-4616-8678-B19AEFB45B45)] struct Blob {
    2.33          SAFEARRAY(BYTE) value;
    2.34 -        BSTR mimeType;
    2.35 -        BSTR filename;
    2.36 +        BSTR MimeType;
    2.37 +        BSTR Filename;
    2.38      };
    2.39  
    2.40      [uuid(D763A8F3-BA23-4229-A037-1BB7BDC3E0C8)] struct TextMessage {
    2.41 -        pEpMsgDirection dir;
    2.42 -        BSTR id;
    2.43 -        BSTR shortmsg;
    2.44 -        BSTR longmsg;
    2.45 -        BSTR longmsgFormatted;
    2.46 -        SAFEARRAY(struct Blob) attachments;
    2.47 -        hyper sent; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
    2.48 -        hyper recv; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
    2.49 -        struct pEpIdentity from;
    2.50 -        SAFEARRAY(struct pEpIdentity) to;
    2.51 -        struct pEpIdentity recvBy;
    2.52 -        SAFEARRAY(struct pEpIdentity) cc;
    2.53 -        SAFEARRAY(struct pEpIdentity) bcc;
    2.54 -        SAFEARRAY(struct pEpIdentity) replyTo;
    2.55 -        SAFEARRAY(BSTR) references;
    2.56 -        SAFEARRAY(BSTR) keywords;
    2.57 -        BSTR comments;
    2.58 -        SAFEARRAY(struct StringPair) optFields;
    2.59 +        pEpMsgDirection Dir;
    2.60 +        BSTR Id;
    2.61 +        BSTR Shortmsg;
    2.62 +        BSTR Longmsg;
    2.63 +        BSTR LongmsgFormatted;
    2.64 +        SAFEARRAY(struct Blob) Attachments;
    2.65 +        hyper Sent; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
    2.66 +        hyper Recv; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
    2.67 +        struct pEpIdentity From;
    2.68 +        SAFEARRAY(struct pEpIdentity) To;
    2.69 +        struct pEpIdentity RecvBy;
    2.70 +        SAFEARRAY(struct pEpIdentity) Cc;
    2.71 +        SAFEARRAY(struct pEpIdentity) Bcc;
    2.72 +        SAFEARRAY(struct pEpIdentity) ReplyTo;
    2.73 +        SAFEARRAY(BSTR) References;
    2.74 +        SAFEARRAY(BSTR) Keywords;
    2.75 +        BSTR Comments;
    2.76 +        SAFEARRAY(struct StringPair) OptFields;
    2.77      };
    2.78  
    2.79      HRESULT EncryptMessage([in] struct TextMessage *src, [out] struct TextMessage * dst, [in] SAFEARRAY(BSTR) extra, [in, defaultvalue(pEpEncryptFlagsNone)] pEpEncryptFlags flags);
     3.1 --- a/pEp_utility.cpp	Wed Oct 05 21:53:59 2016 +0200
     3.2 +++ b/pEp_utility.cpp	Wed Oct 05 23:57:25 2016 +0200
     3.3 @@ -23,17 +23,17 @@
     3.4          pEp_identity_cpp::pEp_identity_cpp(const pEpIdentity *_ident)
     3.5              : me(false)
     3.6          {
     3.7 -            if (_ident->address)
     3.8 -                address = utf8_string(_ident->address);
     3.9 -            if (_ident->fpr)
    3.10 -                fpr = utf8_string(_ident->fpr);
    3.11 -            if (_ident->userId)
    3.12 -                user_id = utf8_string(_ident->userId);
    3.13 -            if (_ident->username)
    3.14 -                username = utf8_string(_ident->username);
    3.15 -            comm_type = _ident->commType;
    3.16 -            if (_ident->lang)
    3.17 -                lang = utf8_string(_ident->lang);
    3.18 +            if (_ident->Address)
    3.19 +                address = utf8_string(_ident->Address);
    3.20 +            if (_ident->Fpr)
    3.21 +                fpr = utf8_string(_ident->Fpr);
    3.22 +            if (_ident->UserId)
    3.23 +                user_id = utf8_string(_ident->UserId);
    3.24 +            if (_ident->UserName)
    3.25 +                username = utf8_string(_ident->UserName);
    3.26 +            comm_type = _ident->CommType;
    3.27 +            if (_ident->Lang)
    3.28 +                lang = utf8_string(_ident->Lang);
    3.29          }
    3.30  
    3.31          pEp_identity * pEp_identity_cpp::to_pEp_identity()
    3.32 @@ -63,12 +63,12 @@
    3.33              if (_ident == NULL)
    3.34                  throw bad_alloc();
    3.35  
    3.36 -            _ident->address = utf16_bstr(this->address);
    3.37 -            _ident->commType = this->comm_type;
    3.38 -            _ident->fpr = utf16_bstr(this->fpr);
    3.39 -            _ident->lang = utf16_bstr(this->lang);
    3.40 -            _ident->username = utf16_bstr(this->username);
    3.41 -            _ident->userId = utf16_bstr(this->user_id);
    3.42 +            _ident->Address = utf16_bstr(this->address);
    3.43 +            _ident->CommType = this->comm_type;
    3.44 +            _ident->Fpr = utf16_bstr(this->fpr);
    3.45 +            _ident->Lang = utf16_bstr(this->lang);
    3.46 +            _ident->UserName = utf16_bstr(this->username);
    3.47 +            _ident->UserId = utf16_bstr(this->user_id);
    3.48  
    3.49              return _ident;
    3.50          }
    3.51 @@ -80,16 +80,16 @@
    3.52              ::memset(ident_s, 0, sizeof(pEpIdentity));
    3.53              if (ident) {
    3.54                  if (ident->address)
    3.55 -                    ident_s->address = utf16_bstr(ident->address);
    3.56 +                    ident_s->Address = utf16_bstr(ident->address);
    3.57                  if (ident->fpr)
    3.58 -                    ident_s->fpr = utf16_bstr(ident->fpr);
    3.59 +                    ident_s->Fpr = utf16_bstr(ident->fpr);
    3.60                  if (ident->user_id)
    3.61 -                    ident_s->userId = utf16_bstr(ident->user_id);
    3.62 +                    ident_s->UserId = utf16_bstr(ident->user_id);
    3.63                  if (ident->username)
    3.64 -                    ident_s->username = utf16_bstr(ident->username);
    3.65 -                ident_s->commType = (pEpComType) ident->comm_type;
    3.66 +                    ident_s->UserName = utf16_bstr(ident->username);
    3.67 +                ident_s->CommType = (pEpComType) ident->comm_type;
    3.68                  if (ident->lang)
    3.69 -                    ident_s->lang = utf16_bstr(ident->lang);
    3.70 +                    ident_s->Lang = utf16_bstr(ident->lang);
    3.71              }
    3.72          }
    3.73  
    3.74 @@ -105,10 +105,10 @@
    3.75              string _user_id;
    3.76              string _username;
    3.77  
    3.78 -            if (ident->address)
    3.79 -                _address = utf8_string(ident->address);
    3.80 -            if (ident->fpr) {
    3.81 -                _fpr = utf8_string(ident->fpr);
    3.82 +            if (ident->Address)
    3.83 +                _address = utf8_string(ident->Address);
    3.84 +            if (ident->Fpr) {
    3.85 +                _fpr = utf8_string(ident->Fpr);
    3.86                  for (auto p = _fpr.begin(); p != _fpr.end(); ++p) {
    3.87                      if (*p >= 'A' && *p <= 'Z')
    3.88                          continue;
    3.89 @@ -117,20 +117,20 @@
    3.90                      throw invalid_argument("invalid hex digits in fingerprint");
    3.91                  }
    3.92              }
    3.93 -            if (ident->userId)
    3.94 -                _user_id = utf8_string(ident->userId);
    3.95 -            if (ident->username)
    3.96 -                _username = utf8_string(ident->username);
    3.97 +            if (ident->UserId)
    3.98 +                _user_id = utf8_string(ident->UserId);
    3.99 +            if (ident->UserName)
   3.100 +                _username = utf8_string(ident->UserName);
   3.101  
   3.102              _ident = ::new_identity(_address.c_str(), _fpr.c_str(), _user_id.c_str(), _username.c_str());
   3.103              assert(_ident);
   3.104              if (_ident == NULL)
   3.105                  throw bad_alloc();
   3.106  
   3.107 -            _ident->comm_type = (PEP_comm_type) ident->commType;
   3.108 +            _ident->comm_type = (PEP_comm_type) ident->CommType;
   3.109  
   3.110 -            if (ident->lang) {
   3.111 -                string _lang = utf8_string(ident->lang);
   3.112 +            if (ident->Lang) {
   3.113 +                string _lang = utf8_string(ident->Lang);
   3.114                  if (_lang.length() != 0) {
   3.115                      if (_lang.length() != 2) {
   3.116                          ::free_identity(_ident);
   3.117 @@ -177,8 +177,8 @@
   3.118              Blob *_blob = new Blob();
   3.119  
   3.120              _blob->value = sa.Detach();
   3.121 -            _blob->mimeType = bstr(tl->mime_type);
   3.122 -            _blob->filename = bstr(tl->filename);
   3.123 +            _blob->MimeType = bstr(tl->mime_type);
   3.124 +            _blob->Filename = bstr(tl->filename);
   3.125  
   3.126              return _blob;
   3.127          }
   3.128 @@ -206,11 +206,11 @@
   3.129  
   3.130          void clear_identity_s(pEpIdentity& ident)
   3.131          {
   3.132 -            SysFreeString(ident.address);
   3.133 -            SysFreeString(ident.fpr);
   3.134 -            SysFreeString(ident.lang);
   3.135 -            SysFreeString(ident.username);
   3.136 -            SysFreeString(ident.userId);
   3.137 +            SysFreeString(ident.Address);
   3.138 +            SysFreeString(ident.Fpr);
   3.139 +            SysFreeString(ident.Lang);
   3.140 +            SysFreeString(ident.UserName);
   3.141 +            SysFreeString(ident.UserId);
   3.142  
   3.143              memset(&ident, 0, sizeof(pEpIdentity));
   3.144          }
   3.145 @@ -244,8 +244,8 @@
   3.146          {
   3.147              StringPair *fld = new StringPair();
   3.148              if (sp) {
   3.149 -                fld->name = bstr(sp->value->key);
   3.150 -                fld->value = bstr(sp->value->value);
   3.151 +                fld->Name = bstr(sp->value->key);
   3.152 +                fld->Value = bstr(sp->value->value);
   3.153              }
   3.154              return fld;
   3.155          }
   3.156 @@ -267,21 +267,21 @@
   3.157  
   3.158          void clear_text_message(TextMessage *msg)
   3.159          {
   3.160 -            SysFreeString(msg->id);
   3.161 -            SysFreeString(msg->shortmsg);
   3.162 -            SysFreeString(msg->longmsg);
   3.163 -            SysFreeString(msg->longmsgFormatted);
   3.164 -            SafeArrayDestroy(msg->attachments);
   3.165 -            clear_identity_s(msg->from);
   3.166 -            SafeArrayDestroy(msg->to);
   3.167 -            clear_identity_s(msg->recvBy);
   3.168 -            SafeArrayDestroy(msg->cc);
   3.169 -            SafeArrayDestroy(msg->bcc);
   3.170 -            SafeArrayDestroy(msg->replyTo);
   3.171 -            SafeArrayDestroy(msg->references);
   3.172 -            SafeArrayDestroy(msg->keywords);
   3.173 -            SysFreeString(msg->comments);
   3.174 -            SafeArrayDestroy(msg->optFields);
   3.175 +            SysFreeString(msg->Id);
   3.176 +            SysFreeString(msg->Shortmsg);
   3.177 +            SysFreeString(msg->Longmsg);
   3.178 +            SysFreeString(msg->LongmsgFormatted);
   3.179 +            SafeArrayDestroy(msg->Attachments);
   3.180 +            clear_identity_s(msg->From);
   3.181 +            SafeArrayDestroy(msg->To);
   3.182 +            clear_identity_s(msg->RecvBy);
   3.183 +            SafeArrayDestroy(msg->Cc);
   3.184 +            SafeArrayDestroy(msg->Bcc);
   3.185 +            SafeArrayDestroy(msg->ReplyTo);
   3.186 +            SafeArrayDestroy(msg->References);
   3.187 +            SafeArrayDestroy(msg->Keywords);
   3.188 +            SysFreeString(msg->Comments);
   3.189 +            SafeArrayDestroy(msg->OptFields);
   3.190  
   3.191              memset(msg, 0, sizeof(TextMessage));
   3.192          }
   3.193 @@ -293,26 +293,26 @@
   3.194  
   3.195              clear_text_message(msg2);
   3.196  
   3.197 -            msg2->dir = (pEpMsgDirection) msg->dir;
   3.198 -            msg2->id = bstr(msg->id);
   3.199 -            msg2->shortmsg = bstr(msg->shortmsg);
   3.200 -            msg2->longmsg = bstr(msg->longmsg);
   3.201 -            msg2->longmsgFormatted = bstr(msg->longmsg_formatted);
   3.202 -            msg2->attachments = array_from_C<Blob, bloblist_t>(msg->attachments);
   3.203 +            msg2->Dir = (pEpMsgDirection) msg->dir;
   3.204 +            msg2->Id = bstr(msg->id);
   3.205 +            msg2->Shortmsg = bstr(msg->shortmsg);
   3.206 +            msg2->Longmsg = bstr(msg->longmsg);
   3.207 +            msg2->LongmsgFormatted = bstr(msg->longmsg_formatted);
   3.208 +            msg2->Attachments = array_from_C<Blob, bloblist_t>(msg->attachments);
   3.209              if (msg->sent)
   3.210 -                msg2->sent = mktime(msg->sent);
   3.211 +                msg2->Sent = mktime(msg->sent);
   3.212              if (msg->recv)
   3.213 -                msg2->recv = mktime(msg->recv);
   3.214 -            msg2->from = identity_s(msg->from);
   3.215 -            msg2->to = array_from_C<pEpIdentity, identity_list>(msg->to);
   3.216 -            msg2->recvBy = identity_s(msg->recv_by);
   3.217 -            msg2->cc = array_from_C<pEpIdentity, identity_list>(msg->cc);
   3.218 -            msg2->bcc = array_from_C<pEpIdentity, identity_list>(msg->bcc);
   3.219 -            msg2->replyTo = array_from_C<pEpIdentity, identity_list>(msg->reply_to);
   3.220 -            msg2->references = string_array(msg->references);
   3.221 -            msg2->keywords = string_array(msg->keywords);
   3.222 -            msg2->comments = bstr(msg->comments);
   3.223 -            msg2->optFields = array_from_C<StringPair, stringpair_list_t>(msg->opt_fields);
   3.224 +                msg2->Recv = mktime(msg->recv);
   3.225 +            msg2->From = identity_s(msg->from);
   3.226 +            msg2->To = array_from_C<pEpIdentity, identity_list>(msg->to);
   3.227 +            msg2->RecvBy = identity_s(msg->recv_by);
   3.228 +            msg2->Cc = array_from_C<pEpIdentity, identity_list>(msg->cc);
   3.229 +            msg2->Bcc = array_from_C<pEpIdentity, identity_list>(msg->bcc);
   3.230 +            msg2->ReplyTo = array_from_C<pEpIdentity, identity_list>(msg->reply_to);
   3.231 +            msg2->References = string_array(msg->references);
   3.232 +            msg2->Keywords = string_array(msg->keywords);
   3.233 +            msg2->Comments = bstr(msg->comments);
   3.234 +            msg2->OptFields = array_from_C<StringPair, stringpair_list_t>(msg->opt_fields);
   3.235          }
   3.236  
   3.237          char * str(BSTR s)
   3.238 @@ -327,8 +327,8 @@
   3.239  
   3.240          void clear_blob(Blob& b)
   3.241          {
   3.242 -            SysFreeString(b.filename);
   3.243 -            SysFreeString(b.mimeType);
   3.244 +            SysFreeString(b.Filename);
   3.245 +            SysFreeString(b.MimeType);
   3.246              SafeArrayDestroy(b.value);
   3.247              memset(&b, 0, sizeof(Blob));
   3.248          }
   3.249 @@ -379,7 +379,7 @@
   3.250                          throw bad_alloc();
   3.251  
   3.252                  }
   3.253 -                _bl = bloblist_add(_bl, buffer, size, str(b.mimeType), str(b.filename));
   3.254 +                _bl = bloblist_add(_bl, buffer, size, str(b.MimeType), str(b.Filename));
   3.255                  if (_bl == NULL) {
   3.256                      free(buffer);
   3.257                      clear_blob(b);
   3.258 @@ -437,7 +437,7 @@
   3.259  
   3.260          stringpair_t *new_stringpair(StringPair *fld)
   3.261          {
   3.262 -            stringpair_t *pair = ::new_stringpair(str(fld->name), str(fld->value));
   3.263 +            stringpair_t *pair = ::new_stringpair(str(fld->Name), str(fld->Value));
   3.264              if (pair == NULL)
   3.265                  throw bad_alloc();
   3.266  
   3.267 @@ -446,8 +446,8 @@
   3.268  
   3.269          void clear_opt_field(StringPair& f)
   3.270          {
   3.271 -            SysFreeString(f.name);
   3.272 -            SysFreeString(f.value);
   3.273 +            SysFreeString(f.Name);
   3.274 +            SysFreeString(f.Value);
   3.275              memset(&f, 0, sizeof(StringPair));
   3.276          }
   3.277  
   3.278 @@ -497,27 +497,27 @@
   3.279          {
   3.280              assert(msg);
   3.281  
   3.282 -            ::message * msg2 = new_message((PEP_msg_direction) msg->dir);
   3.283 +            ::message * msg2 = new_message((PEP_msg_direction) msg->Dir);
   3.284              if (msg2 == NULL)
   3.285                  throw bad_alloc();
   3.286  
   3.287 -            msg2->id = str(msg->id);
   3.288 -            msg2->shortmsg = str(msg->shortmsg);
   3.289 -            msg2->longmsg = str(msg->longmsg);
   3.290 -            msg2->longmsg_formatted = str(msg->longmsgFormatted);
   3.291 -            msg2->attachments = bloblist(msg->attachments);
   3.292 -            msg2->sent = new_timestamp(msg->sent);
   3.293 -            msg2->recv = new_timestamp(msg->recv);
   3.294 -            msg2->from = new_identity(&msg->from);
   3.295 -            msg2->to = identities(msg->to);
   3.296 -            msg2->recv_by = new_identity(&msg->recvBy);
   3.297 -            msg2->cc = identities(msg->cc);
   3.298 -            msg2->bcc = identities(msg->bcc);
   3.299 -            msg2->reply_to = identities(msg->replyTo);
   3.300 -            msg2->references = new_stringlist(msg->references);
   3.301 -            msg2->keywords = new_stringlist(msg->keywords);
   3.302 -            msg2->comments = str(msg->comments);
   3.303 -            msg2->opt_fields = stringpair_list(msg->optFields);
   3.304 +            msg2->id = str(msg->Id);
   3.305 +            msg2->shortmsg = str(msg->Shortmsg);
   3.306 +            msg2->longmsg = str(msg->Longmsg);
   3.307 +            msg2->longmsg_formatted = str(msg->LongmsgFormatted);
   3.308 +            msg2->attachments = bloblist(msg->Attachments);
   3.309 +            msg2->sent = new_timestamp(msg->Sent);
   3.310 +            msg2->recv = new_timestamp(msg->Recv);
   3.311 +            msg2->from = new_identity(&msg->From);
   3.312 +            msg2->to = identities(msg->To);
   3.313 +            msg2->recv_by = new_identity(&msg->RecvBy);
   3.314 +            msg2->cc = identities(msg->Cc);
   3.315 +            msg2->bcc = identities(msg->Bcc);
   3.316 +            msg2->reply_to = identities(msg->ReplyTo);
   3.317 +            msg2->references = new_stringlist(msg->References);
   3.318 +            msg2->keywords = new_stringlist(msg->Keywords);
   3.319 +            msg2->comments = str(msg->Comments);
   3.320 +            msg2->opt_fields = stringpair_list(msg->OptFields);
   3.321  
   3.322              return msg2;
   3.323          }