~renatofilho/buteo-sync-plugins-contacts/solve-eds-conflict

« back to all changes in this revision

Viewing changes to buteo-contact-client/UContactsCustomDetail.cpp

  • Committer: CI Train Bot
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2015-09-24 17:50:44 UTC
  • mfrom: (1.3.53 initial-vr)
  • Revision ID: ci-train-bot@canonical.com-20150924175044-rp0akjs0h1xwxmpj
Implemented buteo contacts sync plugin for google, heavily based on:
  - https://github.com/nemomobile-graveyard/buteo-sync-plugins-google
  - https://github.com/nemomobile/buteo-sync-plugins-social
Approved by: Michael Sheldon

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of buteo-sync-plugins-contacts package
 
3
 *
 
4
 * Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
 
5
 *               2015 Canonical Ltd
 
6
 *
 
7
 * Contributors: Sateesh Kavuri <sateesh.kavuri@gmail.com>
 
8
 *               Mani Chandrasekar <maninc@gmail.com>
 
9
 *               Renato Araujo Oliveira Filho <renato.filho@canonical.com>
 
10
 *
 
11
 * This library is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU Lesser General Public License
 
13
 * version 2.1 as published by the Free Software Foundation.
 
14
 *
 
15
 * This library is distributed in the hope that it will be useful, but
 
16
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
18
 * Lesser General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU Lesser General Public
 
21
 * License along with this library; if not, write to the Free Software
 
22
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
23
 * 02110-1301 USA
 
24
 *
 
25
 */
 
26
 
 
27
#include "UContactsCustomDetail.h"
 
28
 
 
29
// Ubuntu fields
 
30
const QString UContactsCustomDetail::FieldContactETag = "X-GOOGLE-ETAG";
 
31
const QString UContactsCustomDetail::FieldGroupMembershipInfo = "X-GROUP-ID";
 
32
const QString UContactsCustomDetail::FieldRemoteId = "X-REMOTE-ID";
 
33
const QString UContactsCustomDetail::FieldDeletedAt = "X-DELETED-AT";
 
34
const QString UContactsCustomDetail::FieldCreatedAt = "X-CREATED-AT";
 
35
const QString UContactsCustomDetail::FieldContactAvatarETag = "X-AVATAR-REV";
 
36
 
 
37
QContactExtendedDetail
 
38
UContactsCustomDetail::getCustomField(const QContact &contact, const QString &name)
 
39
{
 
40
    foreach (QContactExtendedDetail xd, contact.details<QContactExtendedDetail>()) {
 
41
        if (xd.name() == name) {
 
42
            return xd;
 
43
        }
 
44
    }
 
45
    QContactExtendedDetail xd;
 
46
    xd.setName(name);
 
47
    return xd;
 
48
}
 
49
 
 
50
 
 
51
void UContactsCustomDetail::setCustomField(QtContacts::QContact &contact, const QString &name, const QVariant &value)
 
52
{
 
53
    QContactExtendedDetail xd = getCustomField(contact, name);
 
54
    xd.setData(value);
 
55
    contact.saveDetail(&xd);
 
56
}