forked from andijakl/nfcinteractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nfcmodeltondef.h
83 lines (75 loc) · 3.42 KB
/
nfcmodeltondef.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Andreas Jakl ([email protected])
**
** Released under Nokia Example Code License.
** See license.txt in the main project folder.
**
****************************************************************************/
#ifndef NFCMODELTONDEF_H
#define NFCMODELTONDEF_H
#include <QObject>
#include <QDebug>
#include "nfcrecordmodel.h"
#include "nfcrecorditem.h"
#include <QNdefMessage>
#include <QNdefRecord>
#include <QNdefNfcTextRecord>
#include <QNdefNfcUriRecord>
#include "ndefnfcrecords/ndefnfcsprecord.h"
#include "ndefnfcrecords/ndefnfcmimeimagerecord.h"
#include "ndefnfcrecords/ndefnfcsmarturirecord.h"
#include "ndefnfcrecords/ndefnfcgeorecord.h"
#include "ndefnfcrecords/ndefnfcsmsrecord.h"
#include "ndefnfcrecords/ndefnfcsocialrecord.h"
#include "ndefnfcrecords/ndefnfcstorelinkrecord.h"
#include "ndefnfcrecords/ndefnfclaunchapprecord.h"
#include "ndefnfcrecords/ndefnfcandroidapprecord.h"
#include "nfcstats.h"
// Contact handling
#include "ndefnfcrecords/ndefnfcmimevcardrecord.h"
#include <QContact>
#include <QContactDetail>
#include <QContactName>
#include <QContactNickname>
#include <QContactPhoneNumber>
#include <QContactEmailAddress>
#include <QContactUrl>
#include <QContactOrganization>
#include <QContactAddress>
#include <QContactNote>
#include <QContactBirthday>
#include <QContactThumbnail>
/*!
\brief Builds an NDEF message based on the data stored in the NfcRecordModel.
*/
class NfcModelToNdef : public QObject
{
Q_OBJECT
public:
explicit NfcModelToNdef(QList<NfcRecordItem*> &nfcRecordItems, QObject *parent = 0);
void setNfcStats(NfcStats* nfcStats);
QNdefMessage * convertToNdefMessage();
private:
NdefNfcSpRecord *convertSpFromModel(const int startIndex, int &endIndex);
QNdefNfcUriRecord *convertUriFromModel(const int startIndex, int &endIndex, bool expectHeader = true);
QNdefNfcTextRecord *convertTextFromModel(const int startIndex, int &endIndex, bool expectHeader = true);
NdefNfcMimeImageRecord *convertImageFromModel(const int startIndex, int &endIndex, bool expectHeader = true);
NdefNfcSmsRecord *convertSmsFromModel(const int startIndex, int& endIndex);
NdefNfcMimeVcardRecord *convertBusinessCardFromModel(const int startIndex, int &endIndex);
template<class T> bool contactSetDetail(QContact &contact, const NfcTypes::RecordContent contentType, const QString &value);
NdefNfcSocialRecord *convertSocialNetworkFromModel(const int startIndex, int &endIndex);
NdefNfcGeoRecord *convertGeoFromModel(const int startIndex, int& endIndex);
NdefNfcStoreLinkRecord *convertStoreFromModel(const int startIndex, int &endIndex);
NdefNfcStoreLinkRecord::AppStore appStoreFromRecordContentType(const NfcTypes::RecordContent contentType);
QNdefRecord *convertCustomFromModel(const int startIndex, int &endIndex);
NdefNfcLaunchAppRecord *convertLaunchAppFromModel(const int startIndex, int &endIndex);
NdefNfcAndroidAppRecord *convertAndroidAppRecordFromModel(const int startIndex, int &endIndex);
private:
QList<NfcRecordItem*> &m_recordItems; // Not owned by this class
/*! Count the number of tags read and messages written. (Not owned by this class) */
NfcStats* m_nfcStats;
};
#endif // NFCMODELTONDEF_H