renaming file
authorVolker Birk <vb@pep-project.org>
Fri, 24 Apr 2015 17:40:16 +0200
changeset 912c8f92de54e
parent 8 6fe51215f252
child 10 15fd256d4adb
renaming file
CpEpEngine.h
TextMessage.h
pEpCOMServerAdapter.vcxproj
pEpCOMServerAdapter.vcxproj.filters
pEp_identity_cpp.h
pEp_identity_helper.h
     1.1 --- a/CpEpEngine.h	Fri Apr 24 17:19:41 2015 +0200
     1.2 +++ b/CpEpEngine.h	Fri Apr 24 17:40:16 2015 +0200
     1.3 @@ -9,7 +9,7 @@
     1.4  #include "_IpEpEngineEvents_CP.h"
     1.5  #include "locked_queue.hh"
     1.6  #include "utf8_helper.h"
     1.7 -#include "pEp_identity_cpp.h"
     1.8 +#include "pEp_identity_helper.h"
     1.9  
    1.10  
    1.11  #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
     2.1 --- a/TextMessage.h	Fri Apr 24 17:19:41 2015 +0200
     2.2 +++ b/TextMessage.h	Fri Apr 24 17:40:16 2015 +0200
     2.3 @@ -7,7 +7,7 @@
     2.4  #include "pEpCOMServerAdapter_i.h"
     2.5  #include "_ITextMessageEvents_CP.h"
     2.6  
     2.7 -#include "pEp_identity_cpp.h"
     2.8 +#include "pEp_identity_helper.h"
     2.9  
    2.10  #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
    2.11  #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
     3.1 --- a/pEpCOMServerAdapter.vcxproj	Fri Apr 24 17:19:41 2015 +0200
     3.2 +++ b/pEpCOMServerAdapter.vcxproj	Fri Apr 24 17:40:16 2015 +0200
     3.3 @@ -142,7 +142,7 @@
     3.4      <ClInclude Include="CpEpEngine.h" />
     3.5      <ClInclude Include="locked_queue.hh" />
     3.6      <ClInclude Include="pEpCOMServerAdapter_i.h" />
     3.7 -    <ClInclude Include="pEp_identity_cpp.h" />
     3.8 +    <ClInclude Include="pEp_identity_helper.h" />
     3.9      <ClInclude Include="Resource.h" />
    3.10      <ClInclude Include="stdafx.h" />
    3.11      <ClInclude Include="targetver.h" />
     4.1 --- a/pEpCOMServerAdapter.vcxproj.filters	Fri Apr 24 17:19:41 2015 +0200
     4.2 +++ b/pEpCOMServerAdapter.vcxproj.filters	Fri Apr 24 17:40:16 2015 +0200
     4.3 @@ -75,7 +75,7 @@
     4.4      <ClInclude Include="TextMessage.h">
     4.5        <Filter>Header Files</Filter>
     4.6      </ClInclude>
     4.7 -    <ClInclude Include="pEp_identity_cpp.h">
     4.8 +    <ClInclude Include="pEp_identity_helper.h">
     4.9        <Filter>Header Files</Filter>
    4.10      </ClInclude>
    4.11    </ItemGroup>
     5.1 --- a/pEp_identity_cpp.h	Fri Apr 24 17:19:41 2015 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,183 +0,0 @@
     5.4 -#pragma once
     5.5 -
     5.6 -#include "stdafx.h"
     5.7 -#include "pEpComServerAdapter_i.h"
     5.8 -#include "utf8_helper.h"
     5.9 -
    5.10 -using namespace std;
    5.11 -
    5.12 -struct pEp_identity_cpp {
    5.13 -    string address;
    5.14 -    string fpr;
    5.15 -    string user_id;
    5.16 -    string username;
    5.17 -    pEp_comm_type comm_type;
    5.18 -    string lang;
    5.19 -    bool me;
    5.20 -
    5.21 -    pEp_identity_cpp(
    5.22 -        string _address = string(),
    5.23 -        string _fpr = string(),
    5.24 -        string _user_id = string(),
    5.25 -        string _username = string(),
    5.26 -        pEp_comm_type _comm_type = pEp_ct_unknown,
    5.27 -        string _lang = string()
    5.28 -        ) : address(_address), fpr(_fpr), user_id(_user_id), username(_username), comm_type(_comm_type), lang(_lang), me(false)
    5.29 -    { }
    5.30 -
    5.31 -    pEp_identity_cpp(const ::pEp_identity *_ident)
    5.32 -        : me(false)
    5.33 -    {
    5.34 -        if (_ident->address)
    5.35 -            address = _ident->address;
    5.36 -        if (_ident->fpr)
    5.37 -            fpr = _ident->fpr;
    5.38 -        if (_ident->user_id)
    5.39 -            user_id = _ident->user_id;
    5.40 -        if (_ident->username)
    5.41 -            username = _ident->username;
    5.42 -        comm_type = (pEp_comm_type) _ident->comm_type;
    5.43 -        lang = _ident->lang;
    5.44 -    }
    5.45 -
    5.46 -    pEp_identity_cpp(const pEp_identity_s *_ident)
    5.47 -        : me(false)
    5.48 -    {
    5.49 -        if (_ident->address)
    5.50 -            address = utf8_string(_ident->address);
    5.51 -        if (_ident->fpr)
    5.52 -            fpr = utf8_string(_ident->fpr);
    5.53 -        if (_ident->user_id)
    5.54 -            user_id = utf8_string(_ident->user_id);
    5.55 -        if (_ident->username)
    5.56 -            username = utf8_string(_ident->username);
    5.57 -        comm_type = _ident->comm_type;
    5.58 -        if (_ident->lang)
    5.59 -            lang = utf8_string(_ident->lang);
    5.60 -    }
    5.61 -
    5.62 -    pEp_identity * to_pEp_identity()
    5.63 -    {
    5.64 -        ::pEp_identity *_ident = ::new_identity(this->address.c_str(), this->fpr.c_str(), this->user_id.c_str(), this->username.c_str());
    5.65 -        assert(_ident);
    5.66 -        if (_ident == NULL)
    5.67 -            throw bad_alloc();
    5.68 -
    5.69 -        _ident->comm_type = (::PEP_comm_type) this->comm_type;
    5.70 -        _ident->me = this->me;
    5.71 -
    5.72 -        assert(this->lang.size() == 0 || this->lang.size() == 2);
    5.73 -
    5.74 -        if (this->lang.size()) {
    5.75 -            _ident->lang[0] = this->lang[0];
    5.76 -            _ident->lang[1] = this->lang[1];
    5.77 -        }
    5.78 -
    5.79 -        return _ident;
    5.80 -    }
    5.81 -
    5.82 -    pEp_identity_s * to_pEp_identity_s()
    5.83 -    {
    5.84 -        pEp_identity_s *_ident = (pEp_identity_s *) calloc(1, sizeof(pEp_identity_s));
    5.85 -        assert(_ident);
    5.86 -        if (_ident == NULL)
    5.87 -            throw bad_alloc();
    5.88 -
    5.89 -        _ident->address = utf16_bstr(this->address).Detach();
    5.90 -        _ident->comm_type = this->comm_type;
    5.91 -        _ident->fpr = utf16_bstr(this->fpr).Detach();
    5.92 -        _ident->lang = utf16_bstr(this->lang).Detach();
    5.93 -        _ident->username = utf16_bstr(this->username).Detach();
    5.94 -        _ident->user_id = utf16_bstr(this->user_id).Detach();
    5.95 -
    5.96 -        return _ident;
    5.97 -    }
    5.98 -};
    5.99 -
   5.100 -static void free_pEp_identity_s(pEp_identity_s *ident)
   5.101 -{
   5.102 -    if (ident) {
   5.103 -        SysFreeString(ident->address);
   5.104 -        SysFreeString(ident->fpr);
   5.105 -        SysFreeString(ident->lang);
   5.106 -        SysFreeString(ident->username);
   5.107 -        SysFreeString(ident->user_id);
   5.108 -        free(ident);
   5.109 -    }
   5.110 -}
   5.111 -
   5.112 -static void copy_identity(pEp_identity_s * ident_s, const pEp_identity * ident)
   5.113 -{
   5.114 -    assert(ident_s);
   5.115 -
   5.116 -    ::memset(ident_s, 0, sizeof(pEp_identity_s));
   5.117 -    if (ident) {
   5.118 -        if (ident->address)
   5.119 -            ident_s->address = utf16_bstr(ident->address).Detach();
   5.120 -        if (ident->fpr)
   5.121 -            ident_s->fpr = utf16_bstr(ident->fpr).Detach();
   5.122 -        if (ident->user_id)
   5.123 -            ident_s->user_id = utf16_bstr(ident->user_id).Detach();
   5.124 -        if (ident->username)
   5.125 -            ident_s->username = utf16_bstr(ident->username).Detach();
   5.126 -        ident_s->comm_type = (pEp_comm_type) ident->comm_type;
   5.127 -        if (ident->lang)
   5.128 -            ident_s->lang = utf16_bstr(ident->lang).Detach();
   5.129 -    }
   5.130 -}
   5.131 -
   5.132 -static ::pEp_identity *new_identity(const pEp_identity_s * ident)
   5.133 -{
   5.134 -    ::pEp_identity *_ident;
   5.135 -
   5.136 -    string _address;
   5.137 -    string _fpr;
   5.138 -    string _user_id;
   5.139 -    string _username;
   5.140 -
   5.141 -    if (ident->address)
   5.142 -        _address = utf8_string(ident->address);
   5.143 -    if (ident->fpr) {
   5.144 -        _fpr = utf8_string(ident->fpr);
   5.145 -        for (auto p = _fpr.begin(); p != _fpr.end(); ++p) {
   5.146 -            if (*p >= 'A' && *p <= 'Z')
   5.147 -                continue;
   5.148 -            if (*p >= '0' && *p <= '9')
   5.149 -                continue;
   5.150 -            throw invalid_argument("invalid hex digits in fingerprint");
   5.151 -        }
   5.152 -    }
   5.153 -    if (ident->user_id)
   5.154 -        _user_id = utf8_string(ident->user_id);
   5.155 -    if (ident->username)
   5.156 -        _username = utf8_string(ident->username);
   5.157 -
   5.158 -    _ident = ::new_identity(_address.c_str(), _fpr.c_str(), _user_id.c_str(), _username.c_str());
   5.159 -    assert(_ident);
   5.160 -    if (_ident == NULL)
   5.161 -        throw bad_alloc();
   5.162 -
   5.163 -    _ident->comm_type = (PEP_comm_type) ident->comm_type;
   5.164 -
   5.165 -    if (ident->lang) {
   5.166 -        string _lang = utf8_string(ident->lang);
   5.167 -        if (_lang.length() != 0) {
   5.168 -            if (_lang.length() != 2) {
   5.169 -                ::free_identity(_ident);
   5.170 -                throw invalid_argument("invalid language code");
   5.171 -            }
   5.172 -            if (_lang[0] < 'a' || _lang[0] > 'z') {
   5.173 -                ::free_identity(_ident);
   5.174 -                throw invalid_argument("invalid language code");
   5.175 -            }
   5.176 -            if (_lang[1] < 'a' || _lang[1] > 'z') {
   5.177 -                ::free_identity(_ident);
   5.178 -                throw invalid_argument("invalid language code");
   5.179 -            }
   5.180 -            _ident->lang[0] = _lang[0];
   5.181 -            _ident->lang[1] = _lang[1];
   5.182 -        }
   5.183 -    }
   5.184 -
   5.185 -    return _ident;
   5.186 -}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/pEp_identity_helper.h	Fri Apr 24 17:40:16 2015 +0200
     6.3 @@ -0,0 +1,183 @@
     6.4 +#pragma once
     6.5 +
     6.6 +#include "stdafx.h"
     6.7 +#include "pEpComServerAdapter_i.h"
     6.8 +#include "utf8_helper.h"
     6.9 +
    6.10 +using namespace std;
    6.11 +
    6.12 +struct pEp_identity_cpp {
    6.13 +    string address;
    6.14 +    string fpr;
    6.15 +    string user_id;
    6.16 +    string username;
    6.17 +    pEp_comm_type comm_type;
    6.18 +    string lang;
    6.19 +    bool me;
    6.20 +
    6.21 +    pEp_identity_cpp(
    6.22 +        string _address = string(),
    6.23 +        string _fpr = string(),
    6.24 +        string _user_id = string(),
    6.25 +        string _username = string(),
    6.26 +        pEp_comm_type _comm_type = pEp_ct_unknown,
    6.27 +        string _lang = string()
    6.28 +        ) : address(_address), fpr(_fpr), user_id(_user_id), username(_username), comm_type(_comm_type), lang(_lang), me(false)
    6.29 +    { }
    6.30 +
    6.31 +    pEp_identity_cpp(const ::pEp_identity *_ident)
    6.32 +        : me(false)
    6.33 +    {
    6.34 +        if (_ident->address)
    6.35 +            address = _ident->address;
    6.36 +        if (_ident->fpr)
    6.37 +            fpr = _ident->fpr;
    6.38 +        if (_ident->user_id)
    6.39 +            user_id = _ident->user_id;
    6.40 +        if (_ident->username)
    6.41 +            username = _ident->username;
    6.42 +        comm_type = (pEp_comm_type) _ident->comm_type;
    6.43 +        lang = _ident->lang;
    6.44 +    }
    6.45 +
    6.46 +    pEp_identity_cpp(const pEp_identity_s *_ident)
    6.47 +        : me(false)
    6.48 +    {
    6.49 +        if (_ident->address)
    6.50 +            address = utf8_string(_ident->address);
    6.51 +        if (_ident->fpr)
    6.52 +            fpr = utf8_string(_ident->fpr);
    6.53 +        if (_ident->user_id)
    6.54 +            user_id = utf8_string(_ident->user_id);
    6.55 +        if (_ident->username)
    6.56 +            username = utf8_string(_ident->username);
    6.57 +        comm_type = _ident->comm_type;
    6.58 +        if (_ident->lang)
    6.59 +            lang = utf8_string(_ident->lang);
    6.60 +    }
    6.61 +
    6.62 +    pEp_identity * to_pEp_identity()
    6.63 +    {
    6.64 +        ::pEp_identity *_ident = ::new_identity(this->address.c_str(), this->fpr.c_str(), this->user_id.c_str(), this->username.c_str());
    6.65 +        assert(_ident);
    6.66 +        if (_ident == NULL)
    6.67 +            throw bad_alloc();
    6.68 +
    6.69 +        _ident->comm_type = (::PEP_comm_type) this->comm_type;
    6.70 +        _ident->me = this->me;
    6.71 +
    6.72 +        assert(this->lang.size() == 0 || this->lang.size() == 2);
    6.73 +
    6.74 +        if (this->lang.size()) {
    6.75 +            _ident->lang[0] = this->lang[0];
    6.76 +            _ident->lang[1] = this->lang[1];
    6.77 +        }
    6.78 +
    6.79 +        return _ident;
    6.80 +    }
    6.81 +
    6.82 +    pEp_identity_s * to_pEp_identity_s()
    6.83 +    {
    6.84 +        pEp_identity_s *_ident = (pEp_identity_s *) calloc(1, sizeof(pEp_identity_s));
    6.85 +        assert(_ident);
    6.86 +        if (_ident == NULL)
    6.87 +            throw bad_alloc();
    6.88 +
    6.89 +        _ident->address = utf16_bstr(this->address).Detach();
    6.90 +        _ident->comm_type = this->comm_type;
    6.91 +        _ident->fpr = utf16_bstr(this->fpr).Detach();
    6.92 +        _ident->lang = utf16_bstr(this->lang).Detach();
    6.93 +        _ident->username = utf16_bstr(this->username).Detach();
    6.94 +        _ident->user_id = utf16_bstr(this->user_id).Detach();
    6.95 +
    6.96 +        return _ident;
    6.97 +    }
    6.98 +};
    6.99 +
   6.100 +static void free_pEp_identity_s(pEp_identity_s *ident)
   6.101 +{
   6.102 +    if (ident) {
   6.103 +        SysFreeString(ident->address);
   6.104 +        SysFreeString(ident->fpr);
   6.105 +        SysFreeString(ident->lang);
   6.106 +        SysFreeString(ident->username);
   6.107 +        SysFreeString(ident->user_id);
   6.108 +        free(ident);
   6.109 +    }
   6.110 +}
   6.111 +
   6.112 +static void copy_identity(pEp_identity_s * ident_s, const pEp_identity * ident)
   6.113 +{
   6.114 +    assert(ident_s);
   6.115 +
   6.116 +    ::memset(ident_s, 0, sizeof(pEp_identity_s));
   6.117 +    if (ident) {
   6.118 +        if (ident->address)
   6.119 +            ident_s->address = utf16_bstr(ident->address).Detach();
   6.120 +        if (ident->fpr)
   6.121 +            ident_s->fpr = utf16_bstr(ident->fpr).Detach();
   6.122 +        if (ident->user_id)
   6.123 +            ident_s->user_id = utf16_bstr(ident->user_id).Detach();
   6.124 +        if (ident->username)
   6.125 +            ident_s->username = utf16_bstr(ident->username).Detach();
   6.126 +        ident_s->comm_type = (pEp_comm_type) ident->comm_type;
   6.127 +        if (ident->lang)
   6.128 +            ident_s->lang = utf16_bstr(ident->lang).Detach();
   6.129 +    }
   6.130 +}
   6.131 +
   6.132 +static ::pEp_identity *new_identity(const pEp_identity_s * ident)
   6.133 +{
   6.134 +    ::pEp_identity *_ident;
   6.135 +
   6.136 +    string _address;
   6.137 +    string _fpr;
   6.138 +    string _user_id;
   6.139 +    string _username;
   6.140 +
   6.141 +    if (ident->address)
   6.142 +        _address = utf8_string(ident->address);
   6.143 +    if (ident->fpr) {
   6.144 +        _fpr = utf8_string(ident->fpr);
   6.145 +        for (auto p = _fpr.begin(); p != _fpr.end(); ++p) {
   6.146 +            if (*p >= 'A' && *p <= 'Z')
   6.147 +                continue;
   6.148 +            if (*p >= '0' && *p <= '9')
   6.149 +                continue;
   6.150 +            throw invalid_argument("invalid hex digits in fingerprint");
   6.151 +        }
   6.152 +    }
   6.153 +    if (ident->user_id)
   6.154 +        _user_id = utf8_string(ident->user_id);
   6.155 +    if (ident->username)
   6.156 +        _username = utf8_string(ident->username);
   6.157 +
   6.158 +    _ident = ::new_identity(_address.c_str(), _fpr.c_str(), _user_id.c_str(), _username.c_str());
   6.159 +    assert(_ident);
   6.160 +    if (_ident == NULL)
   6.161 +        throw bad_alloc();
   6.162 +
   6.163 +    _ident->comm_type = (PEP_comm_type) ident->comm_type;
   6.164 +
   6.165 +    if (ident->lang) {
   6.166 +        string _lang = utf8_string(ident->lang);
   6.167 +        if (_lang.length() != 0) {
   6.168 +            if (_lang.length() != 2) {
   6.169 +                ::free_identity(_ident);
   6.170 +                throw invalid_argument("invalid language code");
   6.171 +            }
   6.172 +            if (_lang[0] < 'a' || _lang[0] > 'z') {
   6.173 +                ::free_identity(_ident);
   6.174 +                throw invalid_argument("invalid language code");
   6.175 +            }
   6.176 +            if (_lang[1] < 'a' || _lang[1] > 'z') {
   6.177 +                ::free_identity(_ident);
   6.178 +                throw invalid_argument("invalid language code");
   6.179 +            }
   6.180 +            _ident->lang[0] = _lang[0];
   6.181 +            _ident->lang[1] = _lang[1];
   6.182 +        }
   6.183 +    }
   6.184 +
   6.185 +    return _ident;
   6.186 +}