adding i18n functions
authorVolker Birk <vb@pep-project.org>
Sun, 21 Feb 2016 23:24:31 +0100
changeset 59c03abab41702
parent 58 a0214629bc44
child 60 a91c51e4f42b
adding i18n functions
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Sun Feb 21 18:32:07 2016 +0100
     1.2 +++ b/CpEpEngine.cpp	Sun Feb 21 23:24:31 2016 +0100
     1.3 @@ -453,6 +453,51 @@
     1.4      return S_OK;
     1.5  }
     1.6  
     1.7 +STDMETHODIMP CpEpEngine::get_languagelist(BSTR * languages)
     1.8 +{
     1.9 +    assert(languages);
    1.10 +
    1.11 +    if (!languages)
    1.12 +        return E_INVALIDARG;
    1.13 +
    1.14 +    char *_languages;
    1.15 +    PEP_STATUS status = ::get_languagelist(get_session(), &_languages);
    1.16 +    assert(status == PEP_STATUS_OK);
    1.17 +    if (status == PEP_OUT_OF_MEMORY)
    1.18 +        return E_OUTOFMEMORY;
    1.19 +    if (status != PEP_STATUS_OK || _languages == NULL)
    1.20 +        return FAIL(L"get_languagelist");
    1.21 +
    1.22 +    *languages = utf16_bstr(_languages);
    1.23 +    pEp_free(_languages);
    1.24 +    return S_OK;
    1.25 +}
    1.26 +
    1.27 +STDMETHODIMP CpEpEngine::get_phrase(BSTR lang, LONG phrase_id, BSTR * phrase)
    1.28 +{
    1.29 +    assert(lang && phrase_id >= 0 && phrase);
    1.30 +
    1.31 +    if (!(lang && phrase_id >= 0 && phrase))
    1.32 +        return E_INVALIDARG;
    1.33 +
    1.34 +    string _lang = utf8_string(lang);
    1.35 +    assert(_lang.length() == 2);
    1.36 +    if (_lang.length() != 2)
    1.37 +        return E_INVALIDARG;
    1.38 +
    1.39 +    char *_phrase;
    1.40 +    PEP_STATUS status = ::get_phrase(get_session(), _lang.c_str(), (int) phrase_id, &_phrase);
    1.41 +    assert(status == PEP_STATUS_OK);
    1.42 +    if (status == PEP_OUT_OF_MEMORY)
    1.43 +        return E_OUTOFMEMORY;
    1.44 +    if (status != PEP_STATUS_OK || _phrase == NULL)
    1.45 +        return FAIL(L"get_phrase");
    1.46 +
    1.47 +    *phrase = utf16_bstr(_phrase);
    1.48 +    pEp_free(_phrase);
    1.49 +    return S_OK;
    1.50 +}
    1.51 +
    1.52  STDMETHODIMP CpEpEngine::get_identity(BSTR address, pEp_identity_s * ident)
    1.53  {
    1.54      assert(address);
     2.1 --- a/CpEpEngine.h	Sun Feb 21 18:32:07 2016 +0100
     2.2 +++ b/CpEpEngine.h	Sun Feb 21 23:24:31 2016 +0100
     2.3 @@ -146,6 +146,8 @@
     2.4      STDMETHOD(find_keys)(BSTR pattern, LPSAFEARRAY * key_list);
     2.5      STDMETHOD(send_key)(BSTR pattern);
     2.6      STDMETHOD(get_crashdump_log)(LONG maxlines, BSTR * log);
     2.7 +    STDMETHOD(get_languagelist)(BSTR * languages);
     2.8 +    STDMETHOD(get_phrase)(BSTR lang, LONG phrase_id, BSTR * phrase);
     2.9  
    2.10      // keymanagement API
    2.11  
     3.1 --- a/pEpCOMServerAdapter.idl	Sun Feb 21 18:32:07 2016 +0100
     3.2 +++ b/pEpCOMServerAdapter.idl	Sun Feb 21 23:24:31 2016 +0100
     3.3 @@ -49,6 +49,8 @@
     3.4      HRESULT trustword([in] LONG value, [in, defaultvalue("en")] BSTR lang, [out, retval] BSTR * word);
     3.5      HRESULT trustwords([in] BSTR fpr, [in, defaultvalue("en")] BSTR lang, [in, defaultvalue(0)] LONG max_words, [out, retval] BSTR * words);
     3.6      HRESULT get_crashdump_log([in, defaultvalue(0)] LONG maxlines, [out, retval] BSTR * log);
     3.7 +    HRESULT get_languagelist([out, retval] BSTR * languages);
     3.8 +    HRESULT get_phrase([in] BSTR lang, [in] LONG phrase_id, [out, retval] BSTR * phrase);
     3.9  
    3.10      typedef enum _pEp_comm_type {
    3.11          pEp_ct_unknown = 0,