Browse Source

nice enums

sync
Volker Birk 2 years ago
parent
commit
ee8c159657
3 changed files with 27 additions and 25 deletions
  1. +7
    -4
      src/message.cc
  2. +1
    -1
      src/message.hh
  3. +19
    -20
      src/pEpmodule.cc

+ 7
- 4
src/message.cc View File

@ -313,15 +313,18 @@ namespace pEp {
return pEp::PythonAdapter::decrypt_message(*this, flags);
}
int Message::outgoing_rating()
PEP_rating Message::outgoing_rating()
{
if (_msg->dir != PEP_dir_outgoing)
throw invalid_argument("Message.dir must be outgoing");
if (from().address() == "")
throw invalid_argument("address needed");
throw invalid_argument("from.address needed");
if (from().username() == "")
throw invalid_argument("username needed");
throw invalid_argument("from.username needed");
if (len(to()) + len(cc()) == 0)
throw invalid_argument("either to or cc needed");
PEP_STATUS status = myself(adapter.session(), _msg->from);
_throw_status(status);
@ -330,7 +333,7 @@ namespace pEp {
status = outgoing_message_rating(adapter.session(), *this, &rating);
_throw_status(status);
return (int) rating;
return rating;
}
PEP_color Message::outgoing_color()


+ 1
- 1
src/message.hh View File

@ -132,7 +132,7 @@ namespace pEp {
Message _encrypt(boost::python::list extra, int enc_format=4, int flags=0);
boost::python::tuple decrypt(int flags=0);
int outgoing_rating();
PEP_rating outgoing_rating();
PEP_color outgoing_color();
Message deepcopy(dict& memo);
Message copy();


+ 19
- 20
src/pEpmodule.cc View File

@ -462,26 +462,25 @@ BOOST_PYTHON_MODULE(pEp)
// message API
enum_<PEP_rating>("PEP_rating")
.value("PEP_rating_undefined", PEP_rating_undefined)
.value("PEP_rating_cannot_decrypt", PEP_rating_cannot_decrypt)
.value("PEP_rating_have_no_key", PEP_rating_have_no_key)
.value("PEP_rating_unencrypted", PEP_rating_unencrypted)
.value("PEP_rating_unencrypted_for_some", PEP_rating_unencrypted_for_some)
.value("PEP_rating_unreliable", PEP_rating_unreliable)
.value("PEP_rating_reliable", PEP_rating_reliable)
.value("PEP_rating_trusted", PEP_rating_trusted)
.value("PEP_rating_trusted_and_anonymized", PEP_rating_trusted_and_anonymized)
.value("PEP_rating_fully_anonymous", PEP_rating_fully_anonymous)
.value("PEP_rating_mistrust", PEP_rating_mistrust)
.value("PEP_rating_b0rken", PEP_rating_b0rken)
.value("PEP_rating_under_attack", PEP_rating_under_attack);
enum_<PEP_color>("PEP_color")
.value("PEP_color_no_color", PEP_color_no_color)
.value("PEP_color_yellow", PEP_color_yellow)
.value("PEP_color_green", PEP_color_green)
.value("PEP_color_red", PEP_color_red);
enum_<PEP_rating>("rating")
.value("_undefined", PEP_rating_undefined)
.value("cannot_decrypt", PEP_rating_cannot_decrypt)
.value("have_no_key", PEP_rating_have_no_key)
.value("unencrypted", PEP_rating_unencrypted)
.value("unreliable", PEP_rating_unreliable)
.value("reliable", PEP_rating_reliable)
.value("trusted", PEP_rating_trusted)
.value("trusted_and_anonymized", PEP_rating_trusted_and_anonymized)
.value("fully_anonymous", PEP_rating_fully_anonymous)
.value("mistrust", PEP_rating_mistrust)
.value("b0rken", PEP_rating_b0rken)
.value("under_attack", PEP_rating_under_attack);
enum_<PEP_color>("colorvalue")
.value("no_color", PEP_color_no_color)
.value("yellow", PEP_color_yellow)
.value("green", PEP_color_green)
.value("red", PEP_color_red);
def("incoming_message", &incoming_message,


Loading…
Cancel
Save