COM-30 COM-24: Refactorings keysync
authorMarkus Schaber <markus@pep-security.net>
Tue, 04 Oct 2016 23:00:44 +0200
branchkeysync
changeset 1774d197f1c3abb
parent 176 b46cc11e1ba8
child 178 9f30e2a5f72c
COM-30 COM-24: Refactorings
Drop unused code, and further renamings.
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
pEp_utility.cpp
     1.1 --- a/CpEpEngine.cpp	Tue Oct 04 22:04:52 2016 +0200
     1.2 +++ b/CpEpEngine.cpp	Tue Oct 04 23:00:44 2016 +0200
     1.3 @@ -43,7 +43,7 @@
     1.4  	return S_OK;
     1.5  }
     1.6  
     1.7 -STDMETHODIMP CpEpEngine::log(BSTR title, BSTR entity, BSTR description, BSTR comment)
     1.8 +STDMETHODIMP CpEpEngine::Log(BSTR title, BSTR entity, BSTR description, BSTR comment)
     1.9  {
    1.10  	string _title;
    1.11  	string _entity;
    1.12 @@ -80,315 +80,6 @@
    1.13  		return S_OK;
    1.14  }
    1.15  
    1.16 -
    1.17 -STDMETHODIMP CpEpEngine::decrypt(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEpStatus * status)
    1.18 -{
    1.19 -	assert(ctext);
    1.20 -	assert(ptext);
    1.21 -	assert(key_list);
    1.22 -	assert(status);
    1.23 -
    1.24 -	if (ctext == NULL || ptext == NULL || key_list == NULL || status == NULL) {
    1.25 -		if (ptext)
    1.26 -			*ptext = NULL;
    1.27 -		if (key_list)
    1.28 -			*key_list = NULL;
    1.29 -		if (status)
    1.30 -			*status = pEp_UNENCRYPTED;
    1.31 -		return E_INVALIDARG;
    1.32 -	}
    1.33 -
    1.34 -	string _ctext = utf8_string(ctext);
    1.35 -
    1.36 -	char *_ptext = NULL;
    1.37 -	size_t _psize = 0;
    1.38 -	::stringlist_t *_keylist = NULL;
    1.39 -	PEP_STATUS _status;
    1.40 -
    1.41 -	_status = ::decrypt_and_verify(get_session(), _ctext.c_str(), _ctext.size(), &_ptext, &_psize, &_keylist);
    1.42 -	assert(_status != PEP_OUT_OF_MEMORY);
    1.43 -	if (_status == PEP_OUT_OF_MEMORY)
    1.44 -		return E_OUTOFMEMORY;
    1.45 -
    1.46 -	*status = (pEpStatus)_status;
    1.47 -	if (_ptext == NULL) {
    1.48 -		if (_keylist) {
    1.49 -			string msg;
    1.50 -			if (_keylist->value[0] != 0) {
    1.51 -				msg = _keylist->value;
    1.52 -			}
    1.53 -			else {
    1.54 -				for (::stringlist_t *s = _keylist->next; s != NULL; s = s->next) {
    1.55 -					if (s->value) {
    1.56 -						msg += s->value;
    1.57 -						msg += ";";
    1.58 -					}
    1.59 -				}
    1.60 -			}
    1.61 -			::free_stringlist(_keylist);
    1.62 -
    1.63 -			return FAIL(utf16_bstr(msg));
    1.64 -		}
    1.65 -		else
    1.66 -			return FAIL(L"cannot decrypt");
    1.67 -	}
    1.68 -
    1.69 -	*ptext = utf16_bstr(_ptext);
    1.70 -	pEp_free(_ptext);
    1.71 -
    1.72 -	if (_keylist && _keylist->value)
    1.73 -		*key_list = string_array(_keylist);
    1.74 -	else
    1.75 -		*key_list = NULL;
    1.76 -	::free_stringlist(_keylist);
    1.77 -
    1.78 -	return S_OK;
    1.79 -}
    1.80 -
    1.81 -STDMETHODIMP CpEpEngine::decrypt_b(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEpStatus * status)
    1.82 -{
    1.83 -	assert(ctext);
    1.84 -	assert(ptext);
    1.85 -	assert(key_list);
    1.86 -	assert(status);
    1.87 -
    1.88 -	if (ctext == NULL || ptext == NULL || key_list == NULL || status == NULL) {
    1.89 -		if (ptext)
    1.90 -			*ptext = NULL;
    1.91 -		if (key_list)
    1.92 -			*key_list = NULL;
    1.93 -		if (status)
    1.94 -			*status = pEp_UNENCRYPTED;
    1.95 -		return E_INVALIDARG;
    1.96 -	}
    1.97 -
    1.98 -	// Welcome to Windoze string hell!
    1.99 -
   1.100 -	char *_ctext = NULL;
   1.101 -	_bstr_t bstr_ctext(ctext, true);
   1.102 -	int w_csize = bstr_ctext.length() + 1;
   1.103 -	int _csize = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, (wchar_t *)bstr_ctext, w_csize, NULL, 0, NULL, NULL);
   1.104 -	if (_csize) {
   1.105 -		_ctext = new char[_csize];
   1.106 -		WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, (wchar_t *)bstr_ctext, w_csize, _ctext, _csize, NULL, NULL);
   1.107 -	}
   1.108 -
   1.109 -	char *_ptext = NULL;
   1.110 -	size_t _psize = 0;
   1.111 -	::stringlist_t *_keylist = NULL;
   1.112 -	PEP_STATUS _status;
   1.113 -
   1.114 -	_status = ::decrypt_and_verify(get_session(), _ctext, _csize, &_ptext, &_psize, &_keylist);
   1.115 -	assert(_status != PEP_OUT_OF_MEMORY);
   1.116 -	delete[] _ctext;
   1.117 -	if (_status == PEP_OUT_OF_MEMORY) {
   1.118 -		::free_stringlist(_keylist);
   1.119 -		return E_OUTOFMEMORY;
   1.120 -	}
   1.121 -	*status = (pEpStatus)_status;
   1.122 -
   1.123 -	if (_ptext == NULL) {
   1.124 -		::free_stringlist(_keylist);
   1.125 -		return FAIL(L"decrypt_and_verify");
   1.126 -	}
   1.127 -
   1.128 -	CComSafeArray<BYTE> sa_ptext;
   1.129 -
   1.130 -	HRESULT _result = sa_ptext.Create(_psize, 0);
   1.131 -	assert(_result == S_OK);
   1.132 -	if (_result == E_OUTOFMEMORY) {
   1.133 -		pEp_free(_ptext);
   1.134 -		::free_stringlist(_keylist);
   1.135 -		return E_OUTOFMEMORY;
   1.136 -	}
   1.137 -	else if (_result != S_OK) {
   1.138 -		pEp_free(_ptext);
   1.139 -		::free_stringlist(_keylist);
   1.140 -		return FAIL(L"CComSafeArray<BYTE>::Create");
   1.141 -	}
   1.142 -
   1.143 -	memcpy(sa_ptext.m_psa->pvData, _ptext, _psize);
   1.144 -	*ptext = sa_ptext.Detach();
   1.145 -	::pEp_free(_ptext);
   1.146 -
   1.147 -	if (_keylist && _keylist->value)
   1.148 -		*key_list = string_array(_keylist);
   1.149 -	else
   1.150 -		*key_list = NULL;
   1.151 -	::free_stringlist(_keylist);
   1.152 -
   1.153 -	return S_OK;
   1.154 -}
   1.155 -
   1.156 -STDMETHODIMP CpEpEngine::verify(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEpStatus * verify_status)
   1.157 -{
   1.158 -	assert(text);
   1.159 -	assert(signature);
   1.160 -	assert(key_list);
   1.161 -
   1.162 -	if (text == NULL || signature == NULL || key_list == NULL)
   1.163 -		return E_INVALIDARG;
   1.164 -
   1.165 -	string _text = utf8_string(text);
   1.166 -	string _signature = utf8_string(signature);
   1.167 -
   1.168 -	::stringlist_t *_keylist = NULL;
   1.169 -	PEP_STATUS _status;
   1.170 -	_status = ::verify_text(get_session(), _text.c_str(), _text.size(), _signature.c_str(), _signature.size(), &_keylist);
   1.171 -	assert(_status != PEP_OUT_OF_MEMORY);
   1.172 -	if (_status == PEP_OUT_OF_MEMORY)
   1.173 -		return E_OUTOFMEMORY;
   1.174 -	if (_status == PEP_DECRYPT_WRONG_FORMAT || _status == PEP_UNKNOWN_ERROR)
   1.175 -		return FAIL(L"verify_text");
   1.176 -
   1.177 -	*verify_status = (pEpStatus)_status;
   1.178 -
   1.179 -	if (_keylist && _keylist->value)
   1.180 -		*key_list = string_array(_keylist);
   1.181 -	else
   1.182 -		*key_list = NULL;
   1.183 -	::free_stringlist(_keylist);
   1.184 -
   1.185 -	return S_OK;
   1.186 -}
   1.187 -
   1.188 -STDMETHODIMP CpEpEngine::encrypt(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEpStatus * status)
   1.189 -{
   1.190 -	assert(key_list);
   1.191 -	assert(ptext);
   1.192 -	assert(ctext);
   1.193 -	assert(status);
   1.194 -
   1.195 -	if (ctext == NULL || ptext == NULL || key_list == NULL || status == NULL) {
   1.196 -		if (ctext)
   1.197 -			*ctext = NULL;
   1.198 -		if (status)
   1.199 -			*status = pEp_UNKNOWN_ERROR;
   1.200 -		return E_INVALIDARG;
   1.201 -	}
   1.202 -
   1.203 -	HRESULT result = S_OK;
   1.204 -
   1.205 -	::stringlist_t *_keylist = new_stringlist(key_list);
   1.206 -	string _ptext = utf8_string(ptext);
   1.207 -
   1.208 -	char *_ctext = NULL;
   1.209 -	size_t _csize = 0;
   1.210 -	PEP_STATUS _status;
   1.211 -
   1.212 -	_status = ::encrypt_and_sign(get_session(), _keylist, _ptext.c_str(), _ptext.size(), &_ctext, &_csize);
   1.213 -
   1.214 -	assert(_status != PEP_OUT_OF_MEMORY);
   1.215 -	::free_stringlist(_keylist);
   1.216 -	if (_status == PEP_OUT_OF_MEMORY)
   1.217 -		return E_OUTOFMEMORY;
   1.218 -	*status = (pEpStatus)_status;
   1.219 -
   1.220 -	if (_ctext == NULL)
   1.221 -		return FAIL(L"encrypt_and_sign");
   1.222 -
   1.223 -	*ctext = utf16_bstr(_ctext);
   1.224 -	pEp_free(_ctext);
   1.225 -
   1.226 -	return S_OK;
   1.227 -}
   1.228 -
   1.229 -STDMETHODIMP CpEpEngine::encrypt_b(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEpStatus * status)
   1.230 -{
   1.231 -	assert(key_list);
   1.232 -	assert(ptext);
   1.233 -	assert(ctext);
   1.234 -	assert(status);
   1.235 -
   1.236 -	if (ctext == NULL || ptext == NULL || key_list == NULL || status == NULL) {
   1.237 -		if (ctext)
   1.238 -			*ctext = NULL;
   1.239 -		if (status)
   1.240 -			*status = pEp_UNKNOWN_ERROR;
   1.241 -		return E_INVALIDARG;
   1.242 -	}
   1.243 -
   1.244 -	HRESULT result = S_OK;
   1.245 -
   1.246 -	::stringlist_t *_keylist = new_stringlist(key_list);
   1.247 -
   1.248 -	char *_ctext = NULL;
   1.249 -	size_t _csize = 0;
   1.250 -	::PEP_STATUS _status;
   1.251 -
   1.252 -	_status = ::encrypt_and_sign(get_session(), _keylist, (const char *)ptext->pvData, ptext->rgsabound[0].cElements, &_ctext, &_csize);
   1.253 -	assert(_status != PEP_OUT_OF_MEMORY);
   1.254 -	::free_stringlist(_keylist);
   1.255 -	if (_status == PEP_OUT_OF_MEMORY)
   1.256 -		return E_OUTOFMEMORY;
   1.257 -	*status = (pEpStatus)_status;
   1.258 -
   1.259 -	if (_ctext == NULL)
   1.260 -		return FAIL(L"encrypt_and_sign");
   1.261 -
   1.262 -	*status = (pEpStatus)_status;
   1.263 -	wchar_t *w_ctext = NULL;
   1.264 -	int w_csize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, _ctext, _csize, NULL, 0);
   1.265 -	if (w_csize) {
   1.266 -		w_ctext = new wchar_t[w_csize + 1];
   1.267 -		MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, _ctext, _csize, w_ctext, w_csize);
   1.268 -		w_ctext[w_csize] = 0; // this is for debugging; Visual Studio will crash without that if you're unlucky
   1.269 -	}
   1.270 -	*ctext = ::SysAllocStringLen(w_ctext, w_csize);
   1.271 -	assert(ctext);
   1.272 -	delete[] w_ctext;
   1.273 -	pEp_free(_ctext);
   1.274 -	if (ctext == NULL)
   1.275 -		return E_OUTOFMEMORY;
   1.276 -
   1.277 -	return S_OK;
   1.278 -}
   1.279 -
   1.280 -STDMETHODIMP CpEpEngine::trustword(LONG value, BSTR lang, BSTR * word)
   1.281 -{
   1.282 -	assert(value >= 0 && value <= 65535);
   1.283 -	assert(word);
   1.284 -
   1.285 -	HRESULT result = S_OK;
   1.286 -
   1.287 -	uint16_t _value = 0;
   1.288 -	if (value < 0 || value > 65535)
   1.289 -		result = E_INVALIDARG;
   1.290 -	else
   1.291 -		_value = (uint16_t)value;
   1.292 -
   1.293 -	string _lang = "en";
   1.294 -	if (lang) {
   1.295 -		_lang = utf8_string(lang);
   1.296 -		if (_lang.length() != 2)
   1.297 -			result = E_INVALIDARG;
   1.298 -	}
   1.299 -
   1.300 -	if (word == NULL)
   1.301 -		result = E_INVALIDARG;
   1.302 -
   1.303 -	if (result != S_OK)
   1.304 -		return result;
   1.305 -
   1.306 -	char *_word = NULL;
   1.307 -	size_t _wsize = 0;
   1.308 -
   1.309 -	PEP_STATUS status = ::trustword(get_session(), _value, _lang.c_str(), &_word, &_wsize);
   1.310 -	assert(status != PEP_OUT_OF_MEMORY);
   1.311 -	if (status == PEP_OUT_OF_MEMORY)
   1.312 -		return E_OUTOFMEMORY;
   1.313 -
   1.314 -	if (_word == NULL) {
   1.315 -		*word = NULL;
   1.316 -		return FAIL(L"trustword");
   1.317 -	}
   1.318 -	else {
   1.319 -		*word = utf16_bstr(_word);
   1.320 -		pEp_free(_word);
   1.321 -		return S_OK;
   1.322 -	}
   1.323 -}
   1.324 -
   1.325  STDMETHODIMP CpEpEngine::TrustWords(BSTR fpr, BSTR lang, LONG max_words, BSTR * words)
   1.326  {
   1.327  	assert(fpr);
   1.328 @@ -482,7 +173,7 @@
   1.329  	return S_OK;
   1.330  }
   1.331  
   1.332 -STDMETHODIMP CpEpEngine::GetLanguagelist(BSTR * languages)
   1.333 +STDMETHODIMP CpEpEngine::GetLanguageList(BSTR * languages)
   1.334  {
   1.335  	assert(languages);
   1.336  
   1.337 @@ -495,277 +186,13 @@
   1.338  	if (status == PEP_OUT_OF_MEMORY)
   1.339  		return E_OUTOFMEMORY;
   1.340  	if (status != PEP_STATUS_OK || _languages == NULL)
   1.341 -		return FAIL(L"GetLanguagelist");
   1.342 +		return FAIL(L"GetLanguageList");
   1.343  
   1.344  	*languages = utf16_bstr(_languages);
   1.345  	pEp_free(_languages);
   1.346  	return S_OK;
   1.347  }
   1.348  
   1.349 -STDMETHODIMP CpEpEngine::get_phrase(BSTR lang, LONG phrase_id, BSTR * phrase)
   1.350 -{
   1.351 -	assert(lang && phrase_id >= 0 && phrase);
   1.352 -
   1.353 -	if (!(lang && phrase_id >= 0 && phrase))
   1.354 -		return E_INVALIDARG;
   1.355 -
   1.356 -	string _lang = utf8_string(lang);
   1.357 -	assert(_lang.length() == 2);
   1.358 -	if (_lang.length() != 2)
   1.359 -		return E_INVALIDARG;
   1.360 -
   1.361 -	char *_phrase;
   1.362 -	PEP_STATUS status = ::get_phrase(get_session(), _lang.c_str(), (int)phrase_id, &_phrase);
   1.363 -	assert(status == PEP_STATUS_OK);
   1.364 -	if (status == PEP_OUT_OF_MEMORY)
   1.365 -		return E_OUTOFMEMORY;
   1.366 -	if (status != PEP_STATUS_OK || _phrase == NULL)
   1.367 -		return FAIL(L"get_phrase");
   1.368 -
   1.369 -	*phrase = utf16_bstr(_phrase);
   1.370 -	pEp_free(_phrase);
   1.371 -	return S_OK;
   1.372 -}
   1.373 -
   1.374 -STDMETHODIMP CpEpEngine::get_identity(BSTR address, BSTR user_id, pEpIdentity * ident)
   1.375 -{
   1.376 -	assert(address);
   1.377 -	assert(user_id);
   1.378 -	assert(ident);
   1.379 -
   1.380 -	if (address == NULL)
   1.381 -		return E_INVALIDARG;
   1.382 -	if (user_id == NULL)
   1.383 -		return E_INVALIDARG;
   1.384 -	if (ident == NULL)
   1.385 -		return E_INVALIDARG;
   1.386 -
   1.387 -	string _address = utf8_string(address);
   1.388 -	string _user_id = utf8_string(user_id);
   1.389 -
   1.390 -	::pEp_identity *_ident = NULL;
   1.391 -	PEP_STATUS status = ::get_identity(get_session(), _address.c_str(), _user_id.c_str(), &_ident);
   1.392 -	assert(status != PEP_OUT_OF_MEMORY);
   1.393 -	if (status == PEP_OUT_OF_MEMORY)
   1.394 -		return E_OUTOFMEMORY;
   1.395 -
   1.396 -	if (_ident == NULL) {
   1.397 -		return FAIL(L"get_identity");
   1.398 -	}
   1.399 -
   1.400 -	copy_identity(ident, _ident);
   1.401 -	::free_identity(_ident);
   1.402 -
   1.403 -	return S_OK;
   1.404 -}
   1.405 -
   1.406 -STDMETHODIMP CpEpEngine::set_identity(pEpIdentity * ident)
   1.407 -{
   1.408 -	assert(ident);
   1.409 -	assert(ident->address);
   1.410 -	assert(ident->fpr);
   1.411 -	assert(ident->username);
   1.412 -	assert(ident->user_id);
   1.413 -
   1.414 -	if (ident == NULL || ident->address == NULL || ident->fpr == NULL
   1.415 -		|| ident->username == NULL || ident->user_id == NULL)
   1.416 -		return E_INVALIDARG;
   1.417 -
   1.418 -	::pEp_identity *_ident = new_identity(ident);
   1.419 -	::PEP_STATUS status = ::set_identity(get_session(), _ident);
   1.420 -	::free_identity(_ident);
   1.421 -
   1.422 -	if (status != ::PEP_STATUS_OK)
   1.423 -		return FAIL(L"set_identity");
   1.424 -	else
   1.425 -		return S_OK;
   1.426 -}
   1.427 -
   1.428 -STDMETHODIMP CpEpEngine::generate_keypair(pEpIdentity * ident, BSTR * fpr)
   1.429 -{
   1.430 -	assert(ident);
   1.431 -	assert(ident->address);
   1.432 -	assert(ident->username);
   1.433 -	assert(fpr);
   1.434 -
   1.435 -	if (ident == NULL || ident->address == NULL || ident->username == NULL || fpr == NULL)
   1.436 -		return E_INVALIDARG;
   1.437 -
   1.438 -	::pEp_identity *_ident = new_identity(ident);
   1.439 -	::pEp_free(_ident->fpr);
   1.440 -	_ident->fpr = NULL;
   1.441 -
   1.442 -	::PEP_STATUS status = ::generate_keypair(get_session(), _ident);
   1.443 -	assert(status != ::PEP_OUT_OF_MEMORY);
   1.444 -	if (status == ::PEP_OUT_OF_MEMORY) {
   1.445 -		::free_identity(_ident);
   1.446 -		return E_OUTOFMEMORY;
   1.447 -	}
   1.448 -
   1.449 -	if (_ident->fpr)
   1.450 -		*fpr = utf16_bstr(_ident->fpr);
   1.451 -
   1.452 -	::free_identity(_ident);
   1.453 -
   1.454 -	if (status != ::PEP_STATUS_OK)
   1.455 -		return FAIL(L"generate_keypair");
   1.456 -
   1.457 -	return S_OK;
   1.458 -}
   1.459 -
   1.460 -STDMETHODIMP CpEpEngine::delete_keypair(BSTR fpr)
   1.461 -{
   1.462 -	assert(fpr);
   1.463 -
   1.464 -	if (fpr == NULL)
   1.465 -		return E_INVALIDARG;
   1.466 -
   1.467 -	string _fpr = utf8_string(fpr);
   1.468 -
   1.469 -	::PEP_STATUS status = ::delete_keypair(get_session(), _fpr.c_str());
   1.470 -	assert(status != PEP_OUT_OF_MEMORY);
   1.471 -	if (status == PEP_OUT_OF_MEMORY)
   1.472 -		return E_OUTOFMEMORY;
   1.473 -
   1.474 -	if (status != ::PEP_STATUS_OK)
   1.475 -		return FAIL(L"delete_keypair");
   1.476 -	else
   1.477 -		return S_OK;
   1.478 -}
   1.479 -
   1.480 -STDMETHODIMP CpEpEngine::import_key(BSTR key_data)
   1.481 -{
   1.482 -	assert(key_data);
   1.483 -
   1.484 -	if (key_data == NULL)
   1.485 -		return E_INVALIDARG;
   1.486 -
   1.487 -	string _key_data = utf8_string(key_data);
   1.488 -
   1.489 -	PEP_STATUS status = ::import_key(get_session(), _key_data.c_str(), _key_data.length(), NULL);
   1.490 -	assert(status != PEP_OUT_OF_MEMORY);
   1.491 -	if (status == PEP_OUT_OF_MEMORY)
   1.492 -		return E_OUTOFMEMORY;
   1.493 -
   1.494 -	if (status != pEpStatusOK)
   1.495 -		return FAIL(L"import_key");
   1.496 -	else
   1.497 -		return S_OK;
   1.498 -}
   1.499 -
   1.500 -STDMETHODIMP CpEpEngine::import_key_b(SAFEARRAY * key_data)
   1.501 -{
   1.502 -	assert(key_data);
   1.503 -
   1.504 -	if (key_data == NULL)
   1.505 -		return E_INVALIDARG;
   1.506 -
   1.507 -	::PEP_STATUS status = ::import_key(get_session(), (const char *)key_data->pvData, key_data->rgsabound[0].cElements, NULL);
   1.508 -	assert(status != ::PEP_OUT_OF_MEMORY);
   1.509 -	if (status == ::PEP_OUT_OF_MEMORY)
   1.510 -		return E_OUTOFMEMORY;
   1.511 -
   1.512 -	if (status != ::PEP_STATUS_OK)
   1.513 -		return FAIL(L"import_key");
   1.514 -	else
   1.515 -		return S_OK;
   1.516 -}
   1.517 -
   1.518 -STDMETHODIMP CpEpEngine::export_key(BSTR fpr, BSTR * key_data)
   1.519 -{
   1.520 -	assert(fpr);
   1.521 -	assert(key_data);
   1.522 -
   1.523 -	if (fpr == NULL || key_data == NULL)
   1.524 -		return E_INVALIDARG;
   1.525 -
   1.526 -	string _fpr = utf8_string(fpr);
   1.527 -	char *_key_data = NULL;
   1.528 -	size_t _size = 0;
   1.529 -
   1.530 -	::PEP_STATUS status = ::export_key(get_session(), _fpr.c_str(), &_key_data, &_size);
   1.531 -	assert(status != ::PEP_OUT_OF_MEMORY);
   1.532 -	if (status == ::PEP_OUT_OF_MEMORY)
   1.533 -		return E_OUTOFMEMORY;
   1.534 -
   1.535 -	if (status != ::PEP_STATUS_OK)
   1.536 -		return FAIL(L"export_key");
   1.537 -
   1.538 -	_bstr_t b_key_data(utf16_string(_key_data).c_str());
   1.539 -	pEp_free(_key_data);
   1.540 -	*key_data = b_key_data.Detach();
   1.541 -
   1.542 -	return S_OK;
   1.543 -}
   1.544 -
   1.545 -STDMETHODIMP CpEpEngine::recv_key(BSTR pattern)
   1.546 -{
   1.547 -	assert(pattern);
   1.548 -
   1.549 -	if (pattern == NULL)
   1.550 -		return E_INVALIDARG;
   1.551 -
   1.552 -	string _pattern = utf8_string(pattern);
   1.553 -
   1.554 -	PEP_STATUS status = ::recv_key(get_session(), _pattern.c_str());
   1.555 -	assert(status != PEP_OUT_OF_MEMORY);
   1.556 -	if (status == PEP_OUT_OF_MEMORY)
   1.557 -		return E_OUTOFMEMORY;
   1.558 -
   1.559 -	if (status != ::PEP_STATUS_OK)
   1.560 -		return FAIL(L"recv_key");
   1.561 -	else
   1.562 -		return S_OK;
   1.563 -}
   1.564 -
   1.565 -STDMETHODIMP CpEpEngine::find_keys(BSTR pattern, LPSAFEARRAY * key_list)
   1.566 -{
   1.567 -	assert(pattern);
   1.568 -	assert(key_list);
   1.569 -
   1.570 -	if (pattern == NULL || key_list == NULL)
   1.571 -		return E_INVALIDARG;
   1.572 -
   1.573 -	string _pattern = utf8_string(pattern);
   1.574 -	::stringlist_t *_keylist = NULL;
   1.575 -
   1.576 -	PEP_STATUS status = ::find_keys(get_session(), _pattern.c_str(), &_keylist);
   1.577 -	assert(status != PEP_OUT_OF_MEMORY);
   1.578 -	if (status == PEP_OUT_OF_MEMORY)
   1.579 -		return E_OUTOFMEMORY;
   1.580 -
   1.581 -	if (status != ::PEP_STATUS_OK)
   1.582 -		return FAIL(L"find_keys");
   1.583 -
   1.584 -	if (_keylist && _keylist->value) {
   1.585 -		*key_list = string_array(_keylist);
   1.586 -	}
   1.587 -	else {
   1.588 -		::free_stringlist(_keylist);
   1.589 -		return FAIL(L"find_keys: no keys found");
   1.590 -	}
   1.591 -
   1.592 -	::free_stringlist(_keylist);
   1.593 -	return S_OK;
   1.594 -}
   1.595 -
   1.596 -STDMETHODIMP CpEpEngine::send_key(BSTR pattern)
   1.597 -{
   1.598 -	assert(pattern);
   1.599 -
   1.600 -	if (pattern == NULL)
   1.601 -		return E_INVALIDARG;
   1.602 -
   1.603 -	string _pattern = utf8_string(pattern);
   1.604 -
   1.605 -	::PEP_STATUS status = ::send_key(get_session(), _pattern.c_str());
   1.606 -
   1.607 -	if (status != ::PEP_STATUS_OK)
   1.608 -		return FAIL(L"send_key");
   1.609 -	else
   1.610 -		return S_OK;
   1.611 -}
   1.612 -
   1.613  STDMETHODIMP CpEpEngine::StartKeyserverLookup()
   1.614  {
   1.615  	if (identity_queue.load())
   1.616 @@ -797,24 +224,6 @@
   1.617  	return S_OK;
   1.618  }
   1.619  
   1.620 -STDMETHODIMP CpEpEngine::examine_identity(pEpIdentity * ident)
   1.621 -{
   1.622 -	assert(ident);
   1.623 -	if (ident == NULL)
   1.624 -		return E_INVALIDARG;
   1.625 -
   1.626 -	if (identity_queue.load() == NULL) {
   1.627 -		try {
   1.628 -			identity_queue.load()->push_back(ident);
   1.629 -		}
   1.630 -		catch (bad_alloc) {
   1.631 -			return E_OUTOFMEMORY;
   1.632 -		}
   1.633 -	}
   1.634 -
   1.635 -	return S_OK;
   1.636 -}
   1.637 -
   1.638  STDMETHODIMP CpEpEngine::Myself(struct pEpIdentity *ident, struct pEpIdentity *result)
   1.639  {
   1.640  	assert(ident);
   1.641 @@ -1258,7 +667,7 @@
   1.642  		ss << "TrustPersonalKey called with ";
   1.643  		ss << utf8_string(ident->address);
   1.644  		ss << L": ";
   1.645 -		ss << ident->comm_type;
   1.646 +		ss << ident->commType;
   1.647  		verbose(ss.str());
   1.648  	}
   1.649  
   1.650 @@ -1461,7 +870,7 @@
   1.651  	return S_FALSE;
   1.652  }
   1.653  
   1.654 -STDMETHODIMP CpEpEngine::OpenPGP_list_keyinfo(BSTR search_pattern, LPSAFEARRAY* keyinfo_list) {
   1.655 +STDMETHODIMP CpEpEngine::OpenPGPListKeyinfo(BSTR search_pattern, LPSAFEARRAY* keyinfo_list) {
   1.656  	assert(keyinfo_list);
   1.657  
   1.658  	if (keyinfo_list == NULL)
     2.1 --- a/CpEpEngine.h	Tue Oct 04 22:04:52 2016 +0200
     2.2 +++ b/CpEpEngine.h	Tue Oct 04 23:00:44 2016 +0200
     2.3 @@ -232,35 +232,17 @@
     2.4  
     2.5      // basic API
     2.6  
     2.7 -    STDMETHOD(log)(BSTR title, BSTR entity, BSTR description, BSTR comment);
     2.8 -    STDMETHOD(decrypt)(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_list, pEpStatus * decrypt_status);
     2.9 -    STDMETHOD(decrypt_b)(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY * key_list, pEpStatus * decrypt_status);
    2.10 -    STDMETHOD(encrypt)(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext, pEpStatus * status);
    2.11 -    STDMETHOD(encrypt_b)(SAFEARRAY * key_list, SAFEARRAY * ptext, BSTR * ctext, pEpStatus * status);
    2.12 -    STDMETHOD(trustword)(LONG value, BSTR lang, BSTR * word);
    2.13 +    STDMETHOD(Log)(BSTR title, BSTR entity, BSTR description, BSTR comment);
    2.14      STDMETHOD(TrustWords)(BSTR fpr, BSTR lang, LONG max_words, BSTR * words);
    2.15 -    STDMETHOD(get_identity)(BSTR address, BSTR user_id, pEpIdentity * ident);
    2.16 -    STDMETHOD(set_identity)(pEpIdentity * ident);
    2.17 -    STDMETHOD(generate_keypair)(pEpIdentity * ident, BSTR * fpr);
    2.18 -    STDMETHOD(delete_keypair)(BSTR fpr);
    2.19 -    STDMETHOD(import_key)(BSTR key_data);
    2.20 -    STDMETHOD(import_key_b)(SAFEARRAY * key_data);
    2.21 -    STDMETHOD(export_key)(BSTR fpr, BSTR * key_data);
    2.22 -    STDMETHOD(recv_key)(BSTR pattern);
    2.23 -    STDMETHOD(find_keys)(BSTR pattern, LPSAFEARRAY * key_list);
    2.24 -    STDMETHOD(send_key)(BSTR pattern);
    2.25      STDMETHOD(GetCrashdumpLog)(LONG maxlines, BSTR * log);
    2.26 -    STDMETHOD(GetEngineVersion)(BSTR * engine_version);
    2.27 -    STDMETHOD(GetLanguagelist)(BSTR * languages);
    2.28 -    STDMETHOD(get_phrase)(BSTR lang, LONG phrase_id, BSTR * phrase);
    2.29 +    STDMETHOD(GetEngineVersion)(BSTR * engineVersion);
    2.30 +    STDMETHOD(GetLanguageList)(BSTR * languages);
    2.31  
    2.32      // keymanagement API
    2.33  
    2.34      STDMETHOD(StartKeyserverLookup)();
    2.35      STDMETHOD(StopKeyserverLookup)();
    2.36  
    2.37 -    STDMETHOD(examine_identity)(pEpIdentity * ident);
    2.38 -    STDMETHOD(verify)(BSTR text, BSTR signature, LPSAFEARRAY * key_list, pEpStatus * verify_status);
    2.39      STDMETHOD(Myself)(struct pEpIdentity *ident, struct pEpIdentity *result);
    2.40      STDMETHOD(UpdateIdentity)(struct pEpIdentity *ident, struct pEpIdentity *result);
    2.41      STDMETHOD(KeyMistrusted)(struct pEpIdentity *ident);
    2.42 @@ -289,7 +271,7 @@
    2.43  	STDMETHOD(UnregisterCallbacks)(IpEpEngineCallbacks *obsolete_callback);
    2.44  
    2.45      // PGP compatibility functions
    2.46 -    STDMETHOD(OpenPGP_list_keyinfo)(BSTR search_pattern, LPSAFEARRAY* keyinfo_list);
    2.47 +    STDMETHOD(OpenPGPListKeyinfo)(BSTR search_pattern, LPSAFEARRAY* keyinfo_list);
    2.48  
    2.49  protected:
    2.50  	HRESULT Fire_MessageToSend(
     3.1 --- a/pEpCOMServerAdapter.idl	Tue Oct 04 22:04:52 2016 +0200
     3.2 +++ b/pEpCOMServerAdapter.idl	Tue Oct 04 23:00:44 2016 +0200
     3.3 @@ -35,6 +35,7 @@
     3.4      pointer_default(unique)
     3.5  ]
     3.6  interface IpEpEngine : IUnknown {
     3.7 +
     3.8      // runtime config of the adapter
     3.9  
    3.10      HRESULT VerboseLogging([in] VARIANT_BOOL enable);
    3.11 @@ -46,68 +47,11 @@
    3.12  
    3.13      // basic API
    3.14  
    3.15 -   // // TODO: Remove this enum, it is not needed in the interface, but it currently is still used in the code...
    3.16 -   //typedef [v1_enum] enum pEpStatus {
    3.17 -   //     pEpStatusOK = 0,
    3.18 -
    3.19 -   //     pEp_INIT_CANNOT_LOAD_GPGME = 0x0110,
    3.20 -   //     pEp_INIT_GPGME_INIT_FAILED = 0x0111,
    3.21 -   //     pEp_INIT_NO_GPG_HOME = 0x0112,
    3.22 -   //     pEp_INIT_NETPGP_INIT_FAILED = 0x0113,
    3.23 -
    3.24 -   //     pEp_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
    3.25 -   //     pEp_INIT_CANNOT_OPEN_DB = 0x0121,
    3.26 -   //     pEp_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
    3.27 -
    3.28 -   //     pEp_KEY_NOT_FOUND = 0x0201,
    3.29 -   //     pEp_KEY_HAS_AMBIG_NAME = 0x0202,
    3.30 -   //     pEp_GET_KEY_FAILED = 0x0203,
    3.31 -
    3.32 -   //     pEp_CANNOT_FIND_IDENTITY = 0x0301,
    3.33 -   //     pEp_CANNOT_SET_PERSON = 0x0381,
    3.34 -   //     pEp_CANNOT_SET_PGP_KEYPAIR = 0x0382,
    3.35 -   //     pEp_CANNOT_SET_IDENTITY = 0x0383,
    3.36 -   //     pEp_CANNOT_SET_TRUST = 0x0384,
    3.37 -
    3.38 -   //     pEp_UNENCRYPTED = 0x0400,
    3.39 -   //     pEp_VERIFIED = 0x0401,
    3.40 -   //     pEp_DECRYPTED = 0x0402,
    3.41 -   //     pEp_DECRYPTED_AND_VERIFIED = 0x0403,
    3.42 -   //     pEp_DECRYPT_WRONG_FORMAT = 0x0404,
    3.43 -   //     pEp_DECRYPT_NO_KEY = 0x0405,
    3.44 -   //     pEp_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
    3.45 -   //     pEp_VERIFY_NO_KEY = 0x0407,
    3.46 -   //     pEp_VERIFIED_AND_TRUSTED = 0x0408,
    3.47 -   //     pEp_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
    3.48 -
    3.49 -   //     pEp_TRUSTWORD_NOT_FOUND = 0x0501,
    3.50 -
    3.51 -   //     pEp_CANNOT_CREATE_KEY = 0x0601,
    3.52 -   //     pEp_CANNOT_SEND_KEY = 0x0602,
    3.53 -
    3.54 -   //     pEp_PHRASE_NOT_FOUND = 0x0701,
    3.55 -
    3.56 -   //     pEp_COMMIT_FAILED = 0xff01,
    3.57 -
    3.58 -   //     pEp_CANNOT_CREATE_TEMP_FILE = -5,
    3.59 -   //     pEp_ILLEGAL_VALUE = -4,
    3.60 -   //     pEp_BUFFER_TOO_SMALL = -3,
    3.61 -   //     pEp_OUT_OF_MEMORY = -2,
    3.62 -   //     pEp_UNKNOWN_ERROR = -1
    3.63 -   // } pEpStatus;
    3.64 -
    3.65 -    // HRESULT log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
    3.66 -    // HRESULT decrypt([in] BSTR ctext, [out] BSTR * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEpStatus * decrypt_status);
    3.67 -    // HRESULT decrypt_b([in] BSTR ctext, [out] SAFEARRAY(BYTE) * ptext, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEpStatus * decrypt_status);
    3.68 -    // HRESULT encrypt([in] SAFEARRAY(BSTR) key_list, [in] BSTR ptext, [out] BSTR * ctext, [out, retval] pEpStatus * status);
    3.69 -    // HRESULT encrypt_b([in] SAFEARRAY(BSTR) key_list, [in] SAFEARRAY(BYTE) ptext, [out] BSTR * ctext, [out, retval] pEpStatus * status);
    3.70 -    // HRESULT verify([in] BSTR text, [in] BSTR signature, [out] SAFEARRAY(BSTR) * key_list, [out, retval] pEpStatus * verify_status);
    3.71 -    // HRESULT trustword([in] LONG value, [in, defaultvalue("en")] BSTR lang, [out, retval] BSTR * word);
    3.72 -    HRESULT TrustWords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG max_words, [out, retval] BSTR * words);
    3.73 +    HRESULT Log([in] BSTR title, [in] BSTR entity, [in, defaultvalue("")] BSTR description, [in, defaultvalue("")] BSTR comment);
    3.74 +    HRESULT TrustWords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG maxWords, [out, retval] BSTR * words);
    3.75      HRESULT GetCrashdumpLog([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
    3.76 -    HRESULT GetEngineVersion([out, retval] BSTR * engine_version);
    3.77 -    HRESULT GetLanguagelist([out, retval] BSTR * languages);
    3.78 -    // HRESULT get_phrase([in] BSTR lang, [in] LONG phrase_id, [out, retval] BSTR * phrase);
    3.79 +    HRESULT GetEngineVersion([out, retval] BSTR * engineVersion);
    3.80 +    HRESULT GetLanguageList([out, retval] BSTR * languages);
    3.81  
    3.82      typedef [v1_enum] enum pEpComType {
    3.83          pEpCtUnknown = 0,
    3.84 @@ -172,27 +116,16 @@
    3.85      [uuid(0CB90E62-8A6A-4CA0-99D7-481704051FF0)] struct pEpIdentity {
    3.86          BSTR address;
    3.87          BSTR fpr;
    3.88 -        BSTR user_id;
    3.89 +        BSTR userId;
    3.90          BSTR username;
    3.91 -        pEpComType comm_type;
    3.92 +        pEpComType commType;
    3.93          BSTR lang;
    3.94      };
    3.95 -
    3.96 -    //HRESULT get_identity([in] BSTR address, [in] BSTR user_id, [out, retval] struct pEpIdentity * ident);
    3.97 -    //HRESULT set_identity([in] struct pEpIdentity * ident);
    3.98 -    //HRESULT generate_keypair([in] struct pEpIdentity * ident, [out, retval] BSTR * fpr);
    3.99 -    //HRESULT delete_keypair([in] BSTR fpr);
   3.100 -    //HRESULT import_key([in] BSTR key_data);
   3.101 -    //HRESULT import_key_b([in] SAFEARRAY(BYTE) key_data);
   3.102 -    //HRESULT export_key([in] BSTR fpr, [out, retval] BSTR * key_data);
   3.103 -    //HRESULT recv_key([in] BSTR pattern);
   3.104 -    //HRESULT find_keys([in] BSTR pattern, [out, retval] SAFEARRAY(BSTR) * key_list);
   3.105 -    //HRESULT send_key([in] BSTR pattern);
   3.106 -
   3.107 +    
   3.108 +    // Keymanagement API
   3.109      HRESULT StartKeyserverLookup();
   3.110      HRESULT StopKeyserverLookup();
   3.111  
   3.112 -    //HRESULT examine_identity([in] struct pEpIdentity * ident);
   3.113      HRESULT Myself([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.114      HRESULT UpdateIdentity([in] struct pEpIdentity *ident, [out, retval] struct pEpIdentity *result);
   3.115      HRESULT KeyMistrusted([in] struct pEpIdentity *ident);
   3.116 @@ -208,7 +141,7 @@
   3.117  
   3.118  	// PGP compatibility functions
   3.119  
   3.120 -	HRESULT OpenPGP_list_keyinfo([in] BSTR search_pattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfo_list);
   3.121 +	HRESULT OpenPGPListKeyinfo([in] BSTR searchPattern, [out, retval] SAFEARRAY(struct StringPair)* keyinfoList);
   3.122  
   3.123      // Message API
   3.124  
   3.125 @@ -251,14 +184,6 @@
   3.126          pEpDirOutgoing
   3.127      } pEpMsgDirection;
   3.128  
   3.129 -    //typedef  enum _pEp_enc_format {
   3.130 -    //    pEp_enc_none = 0,                       // message is not encrypted
   3.131 -    //    pEp_enc_pieces,                         // inline PGP + PGP extensions
   3.132 -    //    pEp_enc_S_MIME,                         // RFC5751
   3.133 -    //    pEp_enc_PGP_MIME,                       // RFC3156
   3.134 -    //    pEp_enc_pEp                             // pEp encryption format
   3.135 -    //} pEp_enc_format;
   3.136 -
   3.137      [uuid(3A8A4F13-3402-4C4C-94AB-598D87869380)] struct StringPair {
   3.138          BSTR name;
   3.139          BSTR value;
   3.140 @@ -266,7 +191,7 @@
   3.141  
   3.142      [uuid(61DA7AD4-192E-4616-8678-B19AEFB45B45)] struct Blob {
   3.143          SAFEARRAY(BYTE) value;
   3.144 -        BSTR mime_type;
   3.145 +        BSTR mimeType;
   3.146          BSTR filename;
   3.147      };
   3.148  
   3.149 @@ -275,30 +200,32 @@
   3.150          BSTR id;
   3.151          BSTR shortmsg;
   3.152          BSTR longmsg;
   3.153 -        BSTR longmsg_formatted;
   3.154 +        BSTR longmsgFormatted;
   3.155          SAFEARRAY(struct Blob) attachments;
   3.156          hyper sent; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   3.157          hyper recv; // Timestamp: 64 Bit time_t from mktime(), seconds since January 1, 1970, 0:00 UTC.
   3.158          struct pEpIdentity from;
   3.159          SAFEARRAY(struct pEpIdentity) to;
   3.160 -        struct pEpIdentity recv_by;
   3.161 +        struct pEpIdentity recvBy;
   3.162          SAFEARRAY(struct pEpIdentity) cc;
   3.163          SAFEARRAY(struct pEpIdentity) bcc;
   3.164 -        SAFEARRAY(struct pEpIdentity) reply_to;
   3.165 +        SAFEARRAY(struct pEpIdentity) replyTo;
   3.166          SAFEARRAY(BSTR) references;
   3.167          SAFEARRAY(BSTR) keywords;
   3.168          BSTR comments;
   3.169 -        SAFEARRAY(struct StringPair) opt_fields;
   3.170 +        SAFEARRAY(struct StringPair) optFields;
   3.171      };
   3.172  
   3.173      HRESULT EncryptMessage([in] struct TextMessage *src, [out] struct TextMessage * dst, [in] SAFEARRAY(BSTR) extra, [in, defaultvalue(pEpEncryptFlagsNone)] pEpEncryptFlags flags);
   3.174      HRESULT DecryptMessage([in] struct TextMessage *src, [out] struct TextMessage * dst, [out] SAFEARRAY(BSTR) *keylist, [out] pEpDecryptFlags* flags, [out, retval] pEpRating *rating);
   3.175 +
   3.176      HRESULT OutgoingMessageRating([in] struct TextMessage *msg, [out, retval] pEpRating * pVal);
   3.177      HRESULT IdentityRating([in] struct pEpIdentity * ident, [out, retval] pEpRating * pVal);
   3.178  	HRESULT ColorFromRating([in] pEpRating rating, [out, retval] pEpColor* pVal);
   3.179  
   3.180 -	HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* new_callback);
   3.181 -	HRESULT UnregisterCallbacks([in] IpEpEngineCallbacks* obsolete_callback);
   3.182 +    // callback / keysync API
   3.183 +	HRESULT RegisterCallbacks([in] IpEpEngineCallbacks* newCallback);
   3.184 +	HRESULT UnregisterCallbacks([in] IpEpEngineCallbacks* obsoleteCallback);
   3.185  };
   3.186  
   3.187  [
     4.1 --- a/pEp_utility.cpp	Tue Oct 04 22:04:52 2016 +0200
     4.2 +++ b/pEp_utility.cpp	Tue Oct 04 23:00:44 2016 +0200
     4.3 @@ -27,11 +27,11 @@
     4.4                  address = utf8_string(_ident->address);
     4.5              if (_ident->fpr)
     4.6                  fpr = utf8_string(_ident->fpr);
     4.7 -            if (_ident->user_id)
     4.8 -                user_id = utf8_string(_ident->user_id);
     4.9 +            if (_ident->userId)
    4.10 +                user_id = utf8_string(_ident->userId);
    4.11              if (_ident->username)
    4.12                  username = utf8_string(_ident->username);
    4.13 -            comm_type = _ident->comm_type;
    4.14 +            comm_type = _ident->commType;
    4.15              if (_ident->lang)
    4.16                  lang = utf8_string(_ident->lang);
    4.17          }
    4.18 @@ -64,11 +64,11 @@
    4.19                  throw bad_alloc();
    4.20  
    4.21              _ident->address = utf16_bstr(this->address);
    4.22 -            _ident->comm_type = this->comm_type;
    4.23 +            _ident->commType = this->comm_type;
    4.24              _ident->fpr = utf16_bstr(this->fpr);
    4.25              _ident->lang = utf16_bstr(this->lang);
    4.26              _ident->username = utf16_bstr(this->username);
    4.27 -            _ident->user_id = utf16_bstr(this->user_id);
    4.28 +            _ident->userId = utf16_bstr(this->user_id);
    4.29  
    4.30              return _ident;
    4.31          }
    4.32 @@ -84,10 +84,10 @@
    4.33                  if (ident->fpr)
    4.34                      ident_s->fpr = utf16_bstr(ident->fpr);
    4.35                  if (ident->user_id)
    4.36 -                    ident_s->user_id = utf16_bstr(ident->user_id);
    4.37 +                    ident_s->userId = utf16_bstr(ident->user_id);
    4.38                  if (ident->username)
    4.39                      ident_s->username = utf16_bstr(ident->username);
    4.40 -                ident_s->comm_type = (pEpComType) ident->comm_type;
    4.41 +                ident_s->commType = (pEpComType) ident->comm_type;
    4.42                  if (ident->lang)
    4.43                      ident_s->lang = utf16_bstr(ident->lang);
    4.44              }
    4.45 @@ -117,8 +117,8 @@
    4.46                      throw invalid_argument("invalid hex digits in fingerprint");
    4.47                  }
    4.48              }
    4.49 -            if (ident->user_id)
    4.50 -                _user_id = utf8_string(ident->user_id);
    4.51 +            if (ident->userId)
    4.52 +                _user_id = utf8_string(ident->userId);
    4.53              if (ident->username)
    4.54                  _username = utf8_string(ident->username);
    4.55  
    4.56 @@ -127,7 +127,7 @@
    4.57              if (_ident == NULL)
    4.58                  throw bad_alloc();
    4.59  
    4.60 -            _ident->comm_type = (PEP_comm_type) ident->comm_type;
    4.61 +            _ident->comm_type = (PEP_comm_type) ident->commType;
    4.62  
    4.63              if (ident->lang) {
    4.64                  string _lang = utf8_string(ident->lang);
    4.65 @@ -177,7 +177,7 @@
    4.66              Blob *_blob = new Blob();
    4.67  
    4.68              _blob->value = sa.Detach();
    4.69 -            _blob->mime_type = bstr(tl->mime_type);
    4.70 +            _blob->mimeType = bstr(tl->mime_type);
    4.71              _blob->filename = bstr(tl->filename);
    4.72  
    4.73              return _blob;
    4.74 @@ -210,7 +210,7 @@
    4.75              SysFreeString(ident.fpr);
    4.76              SysFreeString(ident.lang);
    4.77              SysFreeString(ident.username);
    4.78 -            SysFreeString(ident.user_id);
    4.79 +            SysFreeString(ident.userId);
    4.80  
    4.81              memset(&ident, 0, sizeof(pEpIdentity));
    4.82          }
    4.83 @@ -270,18 +270,18 @@
    4.84              SysFreeString(msg->id);
    4.85              SysFreeString(msg->shortmsg);
    4.86              SysFreeString(msg->longmsg);
    4.87 -            SysFreeString(msg->longmsg_formatted);
    4.88 +            SysFreeString(msg->longmsgFormatted);
    4.89              SafeArrayDestroy(msg->attachments);
    4.90              clear_identity_s(msg->from);
    4.91              SafeArrayDestroy(msg->to);
    4.92 -            clear_identity_s(msg->recv_by);
    4.93 +            clear_identity_s(msg->recvBy);
    4.94              SafeArrayDestroy(msg->cc);
    4.95              SafeArrayDestroy(msg->bcc);
    4.96 -            SafeArrayDestroy(msg->reply_to);
    4.97 +            SafeArrayDestroy(msg->replyTo);
    4.98              SafeArrayDestroy(msg->references);
    4.99              SafeArrayDestroy(msg->keywords);
   4.100              SysFreeString(msg->comments);
   4.101 -            SafeArrayDestroy(msg->opt_fields);
   4.102 +            SafeArrayDestroy(msg->optFields);
   4.103  
   4.104              memset(msg, 0, sizeof(TextMessage));
   4.105          }
   4.106 @@ -297,7 +297,7 @@
   4.107              msg2->id = bstr(msg->id);
   4.108              msg2->shortmsg = bstr(msg->shortmsg);
   4.109              msg2->longmsg = bstr(msg->longmsg);
   4.110 -            msg2->longmsg_formatted = bstr(msg->longmsg_formatted);
   4.111 +            msg2->longmsgFormatted = bstr(msg->longmsg_formatted);
   4.112              msg2->attachments = array_from_C<Blob, bloblist_t>(msg->attachments);
   4.113              if (msg->sent)
   4.114                  msg2->sent = mktime(msg->sent);
   4.115 @@ -305,14 +305,14 @@
   4.116                  msg2->recv = mktime(msg->recv);
   4.117              msg2->from = identity_s(msg->from);
   4.118              msg2->to = array_from_C<pEpIdentity, identity_list>(msg->to);
   4.119 -            msg2->recv_by = identity_s(msg->recv_by);
   4.120 +            msg2->recvBy = identity_s(msg->recv_by);
   4.121              msg2->cc = array_from_C<pEpIdentity, identity_list>(msg->cc);
   4.122              msg2->bcc = array_from_C<pEpIdentity, identity_list>(msg->bcc);
   4.123 -            msg2->reply_to = array_from_C<pEpIdentity, identity_list>(msg->reply_to);
   4.124 +            msg2->replyTo = array_from_C<pEpIdentity, identity_list>(msg->reply_to);
   4.125              msg2->references = string_array(msg->references);
   4.126              msg2->keywords = string_array(msg->keywords);
   4.127              msg2->comments = bstr(msg->comments);
   4.128 -            msg2->opt_fields = array_from_C<StringPair, stringpair_list_t>(msg->opt_fields);
   4.129 +            msg2->optFields = array_from_C<StringPair, stringpair_list_t>(msg->opt_fields);
   4.130          }
   4.131  
   4.132          char * str(BSTR s)
   4.133 @@ -328,7 +328,7 @@
   4.134          void clear_blob(Blob& b)
   4.135          {
   4.136              SysFreeString(b.filename);
   4.137 -            SysFreeString(b.mime_type);
   4.138 +            SysFreeString(b.mimeType);
   4.139              SafeArrayDestroy(b.value);
   4.140              memset(&b, 0, sizeof(Blob));
   4.141          }
   4.142 @@ -379,7 +379,7 @@
   4.143                          throw bad_alloc();
   4.144  
   4.145                  }
   4.146 -                _bl = bloblist_add(_bl, buffer, size, str(b.mime_type), str(b.filename));
   4.147 +                _bl = bloblist_add(_bl, buffer, size, str(b.mimeType), str(b.filename));
   4.148                  if (_bl == NULL) {
   4.149                      free(buffer);
   4.150                      clear_blob(b);
   4.151 @@ -504,23 +504,24 @@
   4.152              msg2->id = str(msg->id);
   4.153              msg2->shortmsg = str(msg->shortmsg);
   4.154              msg2->longmsg = str(msg->longmsg);
   4.155 -            msg2->longmsg_formatted = str(msg->longmsg_formatted);
   4.156 +            msg2->longmsg_formatted = str(msg->longmsgFormatted);
   4.157              msg2->attachments = bloblist(msg->attachments);
   4.158              msg2->sent = new_timestamp(msg->sent);
   4.159              msg2->recv = new_timestamp(msg->recv);
   4.160              msg2->from = new_identity(&msg->from);
   4.161              msg2->to = identities(msg->to);
   4.162 -            msg2->recv_by = new_identity(&msg->recv_by);
   4.163 +            msg2->recv_by = new_identity(&msg->recvBy);
   4.164              msg2->cc = identities(msg->cc);
   4.165              msg2->bcc = identities(msg->bcc);
   4.166 -            msg2->reply_to = identities(msg->reply_to);
   4.167 +            msg2->reply_to = identities(msg->replyTo);
   4.168              msg2->references = new_stringlist(msg->references);
   4.169              msg2->keywords = new_stringlist(msg->keywords);
   4.170              msg2->comments = str(msg->comments);
   4.171 -            msg2->opt_fields = stringpair_list(msg->opt_fields);
   4.172 +            msg2->opt_fields = stringpair_list(msg->optFields);
   4.173  
   4.174              return msg2;
   4.175          }
   4.176 +
   4.177  		void opt_field_array_from_C(stringpair_list_t* spair_list, LPSAFEARRAY* pair_list_out) {
   4.178  			assert(spair_list);
   4.179  			assert(pair_list_out);
   4.180 @@ -530,6 +531,7 @@
   4.181  
   4.182  			*pair_list_out = array_from_C<StringPair, stringpair_list_t>(spair_list);
   4.183  		}
   4.184 +
   4.185  		void clear_opt_field_array(LPSAFEARRAY* opt_field_array) {
   4.186  			SafeArrayDestroy(*opt_field_array);
   4.187  			//memset(*opt_field_array, 0, sizeof(SAFEARRAY*));