diff -r e686773b3f54 -r 0ba2181d7c28 logsui/logsengine/inc/logscontact.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logsui/logsengine/inc/logscontact.h Fri Mar 19 09:27:18 2010 +0200 @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef LOGSCONTACT_H +#define LOGSCONTACT_H + +#include +#include +#include + +//forward declarations +class XQServiceRequest; +class LogsDbConnector; +class LogsEvent; + +QTM_USE_NAMESPACE + +/** + * LogsContact can be used to modify or create a contact in phonebook + * + */ +class LogsContact : public QObject +{ + Q_OBJECT + +public: + enum RequestType { + TypeLogsContactOpen, //contact is in phonebook, can open it + TypeLogsContactSave //contact isn't in phonebook, can save it + }; + +public: + + explicit LogsContact(LogsEvent& event, LogsDbConnector& dbConnector); + explicit LogsContact( + unsigned int contactId, const QString& number, LogsDbConnector& dbConnector); + LOGSENGINE_EXPORT ~LogsContact(); + + /** + * Returns allowed request type + */ + LOGSENGINE_EXPORT RequestType allowedRequestType(); + + bool isContactRequestAllowed(); + +public slots: + + /** + * Launch phonebook view for modification of the contact. Will proceed + * only if allowedRequestType() is TypeLogsContactOpen, otherwise returns false. + * Emits openCompeted() signal, when contact modifications are done. + * @return true if opening was called successfully + */ + LOGSENGINE_EXPORT bool open(); + + /** + * Launch phonebook view for creation of a new contact. + * Emits openCompeted() signal, when contact saving is done. + * @return true if saving was called successfully + */ + LOGSENGINE_EXPORT bool save(); + +signals: + + /** + * Indicates that contact modification completed + * @param modified true if contact was modified, false - otherwise + */ + void openCompleted(bool modified); + + /** + * Indicates that contact saving completed + * @param modified true if contact was saved, false - otherwise + */ + void saveCompleted(bool modified); + + +private slots: + + void handleRequestCompleted(const QVariant& result); + + +private: + + /** + * Finds contact from phonebook + * @return contact + */ + QContact contact(); + + /** + * Checks whether contact is in phonebook + * @return true if contact is in phonebook + */ + bool isContactInPhonebook(); + + bool requestFetchService( QString message, const QList &arguments, + bool sync = false ); + + +private: //data + + LogsDbConnector& mDbConnector; + QContact mContact; + + XQServiceRequest* mService; + RequestType mCurrentRequest; + QString mNumber; + unsigned int mContactId; + bool mSaveAsOnlineAccount; + +private: + + friend class UT_LogsContact; + +}; + +#endif // LOGSCONTACT_H