2010-04-19 21:14:47 +02:00
|
|
|
"""
|
|
|
|
This file is part of notmuch.
|
|
|
|
|
|
|
|
Notmuch is free software: you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
Notmuch is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2016-06-02 18:26:14 +02:00
|
|
|
along with notmuch. If not, see <https://www.gnu.org/licenses/>.
|
2010-04-19 21:14:47 +02:00
|
|
|
|
2012-04-29 16:33:06 +02:00
|
|
|
Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>
|
2010-04-19 21:14:47 +02:00
|
|
|
"""
|
2012-05-17 18:13:55 +02:00
|
|
|
|
2012-02-23 00:11:22 +01:00
|
|
|
from ctypes import CDLL, Structure, POINTER
|
2015-05-09 08:13:50 +02:00
|
|
|
from notmuch.version import SOVERSION
|
2010-03-16 11:52:56 +01:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
2010-03-15 15:47:15 +01:00
|
|
|
#package-global instance of the notmuch library
|
2010-04-05 03:03:51 +02:00
|
|
|
try:
|
2013-06-25 16:36:56 +02:00
|
|
|
from os import uname
|
|
|
|
if uname()[0] == 'Darwin':
|
2015-03-07 08:31:14 +01:00
|
|
|
nmlib = CDLL("libnotmuch.{0:s}.dylib".format(SOVERSION))
|
2013-06-25 16:36:56 +02:00
|
|
|
else:
|
2015-03-07 08:31:14 +01:00
|
|
|
nmlib = CDLL("libnotmuch.so.{0:s}".format(SOVERSION))
|
2010-04-05 03:03:51 +02:00
|
|
|
except:
|
|
|
|
raise ImportError("Could not find shared 'notmuch' library.")
|
|
|
|
|
2012-05-17 18:13:55 +02:00
|
|
|
from .compat import Python3StringMixIn, encode_utf8 as _str
|
2012-01-16 13:39:41 +01:00
|
|
|
|
2016-01-08 13:56:10 +01:00
|
|
|
# We import these on behalf of other modules. Silence warning about
|
|
|
|
# these symbols not being used.
|
|
|
|
Python3StringMixIn
|
|
|
|
_str
|
|
|
|
|
2010-03-17 11:44:36 +01:00
|
|
|
class Enum(object):
|
2010-04-05 03:03:51 +02:00
|
|
|
"""Provides ENUMS as "code=Enum(['a','b','c'])" where code.a=0 etc..."""
|
|
|
|
def __init__(self, names):
|
|
|
|
for number, name in enumerate(names):
|
|
|
|
setattr(self, name, number)
|
2010-03-17 11:44:36 +01:00
|
|
|
|
2011-07-12 22:16:04 +02:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchDatabaseS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchDatabaseP = POINTER(NotmuchDatabaseS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchQueryS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchQueryP = POINTER(NotmuchQueryS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchThreadsS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchThreadsP = POINTER(NotmuchThreadsS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchThreadS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchThreadP = POINTER(NotmuchThreadS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchMessagesS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchMessagesP = POINTER(NotmuchMessagesS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchMessageS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchMessageP = POINTER(NotmuchMessageS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchTagsS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchTagsP = POINTER(NotmuchTagsS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchDirectoryS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchDirectoryP = POINTER(NotmuchDirectoryS)
|
|
|
|
|
2011-12-05 22:12:33 +01:00
|
|
|
|
2011-10-10 00:12:53 +02:00
|
|
|
class NotmuchFilenamesS(Structure):
|
|
|
|
pass
|
|
|
|
NotmuchFilenamesP = POINTER(NotmuchFilenamesS)
|