1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 02:09:17 +02:00

revamp api high level page, strike last references of "ffi.CData"

This commit is contained in:
holger krekel 2018-09-15 00:54:36 +02:00
parent 68c401ea76
commit 1f0812c907
3 changed files with 39 additions and 16 deletions

View file

@ -6,21 +6,43 @@ high level API reference
This API is work in progress and may change in versions prior to 1.0. This API is work in progress and may change in versions prior to 1.0.
.. autosummary:: - :class:`deltachat.account.Account` (your main entry point, creates the
other classes)
- :class:`deltachat.chatting.Contact`
- :class:`deltachat.chatting.Chat`
- :class:`deltachat.chatting.Message`
- :class:`deltachat.chatting.MessageState`
deltachat.account Account
deltachat.chatting -------
account module .. autoclass:: deltachat.account.Account
--------------
.. automodule:: deltachat.account
:members: :members:
chatting module Contact
--------------- -------
.. automodule:: deltachat.chatting .. autoclass:: deltachat.chatting.Contact
:members: :members:
Chat
----
.. autoclass:: deltachat.chatting.Chat
:members:
Message
-------
.. autoclass:: deltachat.chatting.Message
:members:
MessageState
------------
.. autoclass:: deltachat.chatting.MessageState
:members:

View file

@ -20,8 +20,9 @@ from .chatting import Contact, Chat, Message
class Account(object): class Account(object):
""" An account contains configuration and provides methods """ Each account is tied to a sqlite database file which is fully managed
for configuration, contact and chat creation and manipulation. by the underlying deltachat c-library. All public Account methods are
meant to be memory-safe and return memory-safe objects.
""" """
def __init__(self, db_path, logid=None): def __init__(self, db_path, logid=None):
@ -86,7 +87,7 @@ class Account(object):
self.check_is_configured() self.check_is_configured()
return Contact(self._dc_context, lib.DC_CONTACT_ID_SELF) return Contact(self._dc_context, lib.DC_CONTACT_ID_SELF)
def create_contact(self, email, name=ffi.NULL): def create_contact(self, email, name=None):
""" create a (new) Contact. If there already is a Contact """ create a (new) Contact. If there already is a Contact
with that e-mail address, it is unblocked and its name is with that e-mail address, it is unblocked and its name is
updated. updated.
@ -100,7 +101,7 @@ class Account(object):
contact_id = lib.dc_create_contact(self._dc_context.p, name, email) contact_id = lib.dc_create_contact(self._dc_context.p, name, email)
return Contact(self._dc_context, contact_id) return Contact(self._dc_context, contact_id)
def get_contacts(self, query=ffi.NULL, with_self=False, only_verified=False): def get_contacts(self, query=None, with_self=False, only_verified=False):
""" get a (filtered) list of contacts. """ get a (filtered) list of contacts.
:param query: if a string is specified, only return contacts :param query: if a string is specified, only return contacts

View file

@ -3,8 +3,8 @@ from .capi import ffi
def convert_to_bytes_utf8(obj): def convert_to_bytes_utf8(obj):
if obj == ffi.NULL: if obj == ffi.NULL or obj is None:
return obj return ffi.NULL
if not isinstance(obj, bytes): if not isinstance(obj, bytes):
return obj.encode("utf8") return obj.encode("utf8")
return obj return obj