pback backend: create obex session on open()
This instantiates the D-Bus wrapper and thus requests a obex-client session. A local cache of the addressbook has been added which will be loaded when the database is opened.
This commit is contained in:
parent
ff0b745f73
commit
82f55381ea
2 changed files with 20 additions and 1 deletions
|
@ -187,6 +187,7 @@ void PbapSession::removeSessionCb(const string &error)
|
|||
PbapSyncSource::PbapSyncSource(const SyncSourceParams ¶ms) :
|
||||
TrackingSyncSource(params)
|
||||
{
|
||||
m_session.reset(new PbapSession());
|
||||
}
|
||||
|
||||
std::string PbapSyncSource::getMimeType() const
|
||||
|
@ -209,11 +210,15 @@ void PbapSyncSource::open()
|
|||
}
|
||||
|
||||
std::string address = database.substr(prefix.size());
|
||||
|
||||
m_session->initSession(address);
|
||||
m_session->pullAll(m_content);
|
||||
m_session->shutdown();
|
||||
}
|
||||
|
||||
bool PbapSyncSource::isEmpty()
|
||||
{
|
||||
return true;
|
||||
return m_content.empty();
|
||||
}
|
||||
|
||||
void PbapSyncSource::close()
|
||||
|
@ -231,10 +236,18 @@ PbapSyncSource::Databases PbapSyncSource::getDatabases()
|
|||
|
||||
void PbapSyncSource::listAllItems(RevisionMap_t &revisions)
|
||||
{
|
||||
typedef std::pair<std::string, std::string> Entry;
|
||||
BOOST_FOREACH(const Entry &entry, m_content) {
|
||||
revisions[entry.first] = "0";
|
||||
}
|
||||
}
|
||||
|
||||
void PbapSyncSource::readItem(const string &uid, std::string &item, bool raw)
|
||||
{
|
||||
Content::iterator it = m_content.find(uid);
|
||||
if(it != m_content.end()) {
|
||||
item = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
TrackingSyncSource::InsertItemResult PbapSyncSource::insertItem(const string &uid, const std::string &item, bool raw)
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <syncevo/declarations.h>
|
||||
SE_BEGIN_CXX
|
||||
|
||||
class PbapSession;
|
||||
|
||||
class PbapSyncSource : public TrackingSyncSource, private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
@ -54,6 +56,10 @@ class PbapSyncSource : public TrackingSyncSource, private boost::noncopyable
|
|||
virtual void removeItem(const string &uid);
|
||||
|
||||
private:
|
||||
std::auto_ptr<PbapSession> m_session;
|
||||
|
||||
typedef std::map<std::string, std::string> Content;
|
||||
Content m_content;
|
||||
};
|
||||
|
||||
SE_END_CXX
|
||||
|
|
Loading…
Reference in a new issue