Changeset 3
- Timestamp:
- 02/03/10 23:56:22 (2 years ago)
- Location:
- libQtGdata/trunk
- Files:
-
- 8 edited
-
QtGdata.pro (modified) (1 diff)
-
qtgdata.cpp (modified) (1 diff)
-
qtgdata.h (modified) (1 diff)
-
qtgdata_calendar.cpp (modified) (1 diff)
-
qtgdata_calendar.h (modified) (1 diff)
-
qtgdata_contact.cpp (modified) (1 diff)
-
qtgdata_contacts.cpp (modified) (3 diffs)
-
qtgdata_contacts.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libQtGdata/trunk/QtGdata.pro
r2 r3 12 12 qtgdata_calendar.cpp \ 13 13 helper/syncnetworkaccessmanager.cpp \ 14 qtgdata_contacts.cpp 14 qtgdata_contacts.cpp \ 15 qtgdata_contact.cpp 15 16 HEADERS += qtgdata.h \ 16 17 QtGdata_global.h \ -
libQtGdata/trunk/qtgdata.cpp
r2 r3 114 114 } 115 115 116 QByteArray QtGdata::getFeed(const QString url )116 QByteArray QtGdata::getFeed(const QString url, const QString version) 117 117 { 118 118 QNetworkRequest request; 119 119 request.setUrl(QUrl(url)); 120 120 request.setRawHeader("User-Agent", "QtGdata 0.0.1"); 121 request.setRawHeader("GData-Version", "2");121 request.setRawHeader("GData-Version", version.toAscii()); 122 122 123 123 QString authHeader = "GoogleLogin auth=" + Auth; -
libQtGdata/trunk/qtgdata.h
r2 r3 34 34 const GDATA_ACCOUNT_TYPE accountType = QtGdata::GDATA_ACCOUNT_TYPE_HOSTED_OR_GOOGLE); 35 35 36 QByteArray getFeed(const QString url );36 QByteArray getFeed(const QString url, const QString version = "2"); 37 37 38 38 QString email; -
libQtGdata/trunk/qtgdata_calendar.cpp
r2 r3 8 8 9 9 } 10 11 QStringList QtGdata_calendar::getCalendars()12 {13 14 } -
libQtGdata/trunk/qtgdata_calendar.h
r2 r3 12 12 QtGdata_calendar(const QString username, const QString password); 13 13 14 QStringList getCalendars();15 14 }; 16 15 -
libQtGdata/trunk/qtgdata_contact.cpp
r2 r3 1 #include "qtgdata_contact .h"1 #include "qtgdata_contacts.h" 2 2 3 QtGdata_contact::QtGdata_contact() 4 { 5 6 } 7 8 void QtGdata_contact::setName(const QString name) 9 { 10 this->name = name; 11 } 12 13 void QtGdata_contact::setUpdated(const QDateTime updated) 14 { 15 this->updated = updated; 16 } 17 18 /** 19 * @param email Email address 20 * @param type What kind of email (home/work/other) 21 * @param primary Boolean indicating if this is the primary email 22 */ 23 void QtGdata_contact::addEmail(const QString email, 24 const QtGdata_contact::GDATA_CONTACT_EMAIL type, 25 const bool primary) 26 { 27 this->email.insert(email, type); 28 29 if (primary) { 30 primary_email = email; 31 } 32 } 33 34 void QtGdata_contact::addPhone(const QString phonenumber, 35 const QtGdata_contact::GDATA_CONTACT_PHONE type) 36 { 37 phone.insert(phonenumber, type); 38 } 39 40 41 void QtGdata_contact::setGender(const QString gender) 42 { 43 this->gender = gender; 44 } 45 46 QString QtGdata_contact::getName() 47 { 48 return name; 49 } 50 51 QString QtGdata_contact::getGender() 52 { 53 return gender; 54 } 55 56 QDateTime QtGdata_contact::getUpdated() 57 { 58 return updated; 59 } -
libQtGdata/trunk/qtgdata_contacts.cpp
r2 r3 19 19 20 20 21 xml = getFeed(url );21 xml = getFeed(url, "3"); 22 22 parseContacts(xml); 23 23 24 24 while(!next.isEmpty()) { 25 xml = getFeed(next );25 xml = getFeed(next, "3"); 26 26 parseContacts(xml); 27 27 } … … 29 29 } 30 30 31 /* 32 * Parse an XML file with contact info 33 */ 31 34 void QtGdata_contacts::parseContacts(QByteArray xml) 32 35 { … … 73 76 } 74 77 75 QDomNodeList contacts = root.elementsByTagName("entry"); 78 /* Parse actual contacts */ 79 nl = root.elementsByTagName("entry"); 80 for (int i = 0; i < nl.size(); i++) { 81 QtGdata_contact c; 76 82 77 for (int i = 0; i < contacts.size(); i++) {78 n = contacts.at(i).toElement();83 n = nl.at(i).toElement(); 84 QDomNodeList nl2 = n.childNodes(); 79 85 80 nl = n.elementsByTagName("title"); 86 for (int j = 0; j < nl2.size(); j++) { 87 n = nl2.at(j).toElement(); 81 88 82 if (nl.size() == 1) { 83 qDebug() << nl.at(0).toElement().text(); 89 /* Birthday */ 90 if (n.tagName() == "gContact:birthday") { 91 QString birthday = n.attribute("when"); 92 93 /* TODO parse birthday 94 see: http://code.google.com/apis/contacts/docs/3.0/reference.html#gcBirthday 95 */ 96 } 97 /* Email */ 98 else if (n.tagName() == "gd:email") { 99 QString email = n.attribute("address"); 100 QString rel = n.attribute("rel"); 101 bool primary = (n.hasAttribute("primary") && n.attribute("primary") == "yes"); 102 103 QtGdata_contact::GDATA_CONTACT_EMAIL type = QtGdata_contact::GDATA_CONTACT_EMAIL_OTHER; 104 if (rel == "http://schemas.google.com/g/2005#home") { 105 type = QtGdata_contact::GDATA_CONTACT_EMAIL_HOME; 106 } else if (rel == "http://schemas.google.com/g/2005#work") { 107 type = QtGdata_contact::GDATA_CONTACT_EMAIL_WORK; 108 } 109 110 c.addEmail(email, type, primary); 111 } 112 /* Phone number */ 113 else if(n.tagName() == "gd:phoneNumber") { 114 QString ref = n.attribute("rel"); 115 QString number = n.text(); 116 117 QtGdata_contact::GDATA_CONTACT_PHONE type = QtGdata_contact::GDATA_CONTACT_PHONE_OTHER; 118 if (ref == "http://schemas.google.com/g/2005#mobile") { 119 type = QtGdata_contact::GDATA_CONTACT_PHONE_MOBILE; 120 } 121 /* Add other */ 122 123 c.addPhone(number, type); 124 } 125 /* Update */ 126 else if (n.tagName() == "updated") { 127 QDateTime updated = QDateTime::fromString(n.text(), "yyyy-M-ddThh:mm:ss.zzzZ"); 128 updated.setTimeSpec(Qt::UTC); 129 c.setUpdated(updated); 130 } 84 131 } 132 133 contacts.append(c); 85 134 } 86 135 } -
libQtGdata/trunk/qtgdata_contacts.h
r2 r3 1 #ifndef QTGDATA_CONTACT _H2 #define QTGDATA_CONTACT _H1 #ifndef QTGDATA_CONTACTS_H 2 #define QTGDATA_CONTACTS_H 3 3 4 4 #include <qtgdata.h> … … 7 7 #include <QByteArray> 8 8 #include <QDateTime> 9 #include <QUrl> 9 #include <QMap> 10 11 class QtGdata_contact 12 { 13 public: 14 enum GDATA_CONTACT_EMAIL { 15 GDATA_CONTACT_EMAIL_OTHER, 16 GDATA_CONTACT_EMAIL_HOME, 17 GDATA_CONTACT_EMAIL_WORK, 18 }; 19 20 enum GDATA_CONTACT_PHONE { 21 GDATA_CONTACT_PHONE_OTHER, 22 GDATA_CONTACT_PHONE_HOME, 23 GDATA_CONTACT_PHONE_HOME_FAX, 24 GDATA_CONTACT_PHONE_WORK, 25 GDATA_CONTACT_PHONE_WORK_FAX, 26 GDATA_CONTACT_PHONE_MOBILE, 27 GDATA_CONTACT_PHONE_PAGER 28 }; 29 30 QtGdata_contact(); 31 32 /* Getters */ 33 QString getGender(); 34 QString getName(); 35 QDateTime getUpdated(); 36 37 /* Adders */ 38 void addEmail(const QString email, 39 const QtGdata_contact::GDATA_CONTACT_EMAIL type = QtGdata_contact::GDATA_CONTACT_EMAIL_OTHER, 40 const bool primary = false); 41 void addPhone(const QString phonenumber, 42 const QtGdata_contact::GDATA_CONTACT_PHONE type = QtGdata_contact::GDATA_CONTACT_PHONE_OTHER); 43 44 /* Setters */ 45 void setGender(const QString gender); 46 void setName(const QString name); 47 void setUpdated(const QDateTime updated); 48 49 private: 50 //QDate birthday; 51 QMap<QString, QtGdata_contact::GDATA_CONTACT_EMAIL> email; 52 QString primary_email; 53 QString gender; 54 QString name; 55 QMap<QString, QtGdata_contact::GDATA_CONTACT_PHONE> phone; 56 QDateTime updated; 57 }; 10 58 11 59 class QtGdata_contacts : public QtGdata … … 21 69 QDateTime update; 22 70 QString next; 71 72 QList<QtGdata_contact> contacts; 23 73 }; 24 74 25 #endif // QTGDATA_CONTACT_H 75 76 #endif // QTGDATA_CONTACTS_H
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)