Skip to content
This repository has been archived by the owner on Apr 18, 2019. It is now read-only.

Commit

Permalink
Remove contact method added (not tested yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Kormalev committed Mar 16, 2012
1 parent f773df7 commit b8243aa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/plugins/contacts.cpp
Expand Up @@ -81,6 +81,19 @@ void Contacts::saveContact(int scId, int ecId, const QVariantMap &params)
qDeleteAll(detailsToDelete);
}

void Contacts::removeContact(int scId, int ecId, const QString &guid)
{
Q_UNUSED(scId)
Q_UNUSED(ecId)

QContactDetailFilter idFilter;
idFilter.setDetailDefinitionName(QContactGuid::DefinitionName, QContactGuid::FieldGuid);
idFilter.setValue(guid);
idFilter.setMatchFlags(QContactFilter::MatchExactly);
QList<QContactLocalId> contacts = m_manager->contactIds(idFilter);
m_manager->removeContacts(contacts);
}

void Contacts::findContacts(int scId, int ecId, const QStringList &fields, const QString &filter, bool multiple)
{
qDebug() << Q_FUNC_INFO << filter << fields << multiple;
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/contacts.h
Expand Up @@ -15,15 +15,14 @@

#ifdef QTM_NAMESPACE
QTM_BEGIN_NAMESPACE
#elif defined QTCONTACTS_USE_NAMESPACE
QTCONTACTS_BEGIN_NAMESPACE
#endif
class QContact;
class QContactManager;
#ifdef QTM_NAMESPACE
QTM_END_NAMESPACE
QTM_USE_NAMESPACE
#elif defined QTCONTACTS_USE_NAMESPACE
QTCONTACTS_BEGIN_NAMESPACE
class QContact;
class QContactManager;
QTCONTACTS_END_NAMESPACE
QTCONTACTS_USE_NAMESPACE
#endif
Expand All @@ -41,6 +40,7 @@ class Contacts : public CPlugin

public slots:
void saveContact(int scId, int ecId, const QVariantMap &params);
void removeContact(int scId, int ecId, const QString &guid);
void findContacts(int scId, int ecId, const QStringList &fields, const QString &filter, bool multiple);

private:
Expand Down
17 changes: 15 additions & 2 deletions www/js/contacts.js
Expand Up @@ -173,7 +173,7 @@ Contact.create = function(obj) {
return result
}

Contact.prototype.id = ""
Contact.prototype.id = null
Contact.prototype.displayName = ""
Contact.prototype.name = new ContactName()
Contact.prototype.nickname = ""
Expand All @@ -189,10 +189,23 @@ Contact.prototype.categories = []
Contact.prototype.urls = []

Contact.prototype.clone = function() {

var newContact = Contact.create(this)
newContact.id = null
return newContact
}

Contact.prototype.remove = function(onSaveSuccess,onSaveError) {
if( typeof contactSuccess !== "function" ) return
if( typeof contactError !== "function" ) contactError = function() {}

//TODO: call onSaveError here
if (this.id == null || this.id == "")
return

Cordova.exec( function() {
contactSuccess()
}, contactError, "com.cordova.Contacts", "removeContact", [ this.id ] )


}

Expand Down

0 comments on commit b8243aa

Please sign in to comment.