diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-04 20:41:13 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-04 20:41:13 +0000 |
commit | 6b3ded37e4a4825be2df3612bdcbb7dfc00a1800 (patch) | |
tree | d6b6290439e207be3bb28718a2829e298db08342 /plugins/!NotAdopted/HistoryStats/statistic.h | |
parent | d4ed74b1750b5389f22fd67246985ba782d2648b (diff) |
HistoryStats sources
git-svn-id: http://svn.miranda-ng.org/main/trunk@8397 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/HistoryStats/statistic.h')
-rw-r--r-- | plugins/!NotAdopted/HistoryStats/statistic.h | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/HistoryStats/statistic.h b/plugins/!NotAdopted/HistoryStats/statistic.h new file mode 100644 index 0000000000..21dbd5acb5 --- /dev/null +++ b/plugins/!NotAdopted/HistoryStats/statistic.h @@ -0,0 +1,210 @@ +#if !defined(HISTORYSTATS_GUARD_STATISTIC_H)
+#define HISTORYSTATS_GUARD_STATISTIC_H
+
+#include "_globals.h"
+#include "_consts.h"
+
+#include <vector>
+#include <map>
+#include <set>
+#include <list>
+
+#include "settings.h"
+#include "protocol.h"
+#include "message.h"
+
+class Contact; // forward declaration instead of #include "contact.h"
+
+class Statistic
+ : private pattern::NotCopyable<Statistic>
+{
+public:
+ enum InvocationSource {
+ fromOptions,
+ fromStartup,
+ fromMenu,
+ };
+
+ enum DBEventTypeRaw {
+ ICQEVENTTYPE_AUTH_GRANTED = 2004, // from ICQ
+ ICQEVENTTYPE_AUTH_DENIED = 2005, // from ICQ
+ ICQEVENTTYPE_BROADCAST = 2006, // from ICQ
+ ICQEVENTTYPE_SELF_REMOVE = 2007, // from ICQ
+ ICQEVENTTYPE_FUTURE_AUTH = 2008, // from ICQ
+ EVENTTYPE_SMTPSIMPLE = 2350, // from SMTP Simple
+ EVENTTYPE_VOICE_CALL = 8739, // from pescuma
+ EVENTTYPE_NICKNAMECHANGE = 9001, // from pescuma
+ EVENTTYPE_STATUSMESSAGECHANGE = 9002, // from pescuma
+ EVENTTYPE_AVATARCHANGE = 9003, // from pescuma
+ EVENTTYPE_CONTACTLEFTCHANNEL = 9004, // from pescuma
+ EVENTTYPE_WAT_REQUEST = 9601, // from WATrack
+ EVENTTYPE_WAT_ANSWER = 9602, // from WATrack
+ EVENTTYPE_WAT_ERROR = 9603, // from WATrack
+ EVENTTYPE_STATUSCHANGE = 25368, // from SRMMs
+ };
+
+ enum DBEventType {
+ // messages
+ etMessage = EVENTTYPE_MESSAGE,
+ // other events
+ etFile = EVENTTYPE_FILE,
+ etURL = EVENTTYPE_URL,
+ etICQSMS = ICQEVENTTYPE_SMS,
+ etICQWebPager = ICQEVENTTYPE_WEBPAGER,
+ etICQEMailExpress = ICQEVENTTYPE_EMAILEXPRESS,
+ etSMTPSimple = EVENTTYPE_SMTPSIMPLE,
+ etICQBroadcast = ICQEVENTTYPE_BROADCAST,
+ etVoiceCall = EVENTTYPE_VOICE_CALL,
+ // authorization and contacts
+ etAuthRequest = EVENTTYPE_AUTHREQUEST,
+ etAdded = EVENTTYPE_ADDED,
+ etContacts = EVENTTYPE_CONTACTS,
+ etICQAuthGranted = ICQEVENTTYPE_AUTH_GRANTED,
+ etICQAuthDenied = ICQEVENTTYPE_AUTH_DENIED,
+ etICQSelfRemove = ICQEVENTTYPE_SELF_REMOVE,
+ etICQFutureAuth = ICQEVENTTYPE_FUTURE_AUTH,
+ // status/avatar/nick/... changes
+ etStatusChange = EVENTTYPE_STATUSCHANGE,
+ etNickNameChange = EVENTTYPE_NICKNAMECHANGE,
+ etStatusMessageChange = EVENTTYPE_STATUSMESSAGECHANGE,
+ etAvatarChange = EVENTTYPE_AVATARCHANGE,
+ etContactLeftChannel = EVENTTYPE_CONTACTLEFTCHANNEL,
+ // WaTrack events
+ etWATRequest = EVENTTYPE_WAT_REQUEST,
+ etWATAnswer = EVENTTYPE_WAT_ANSWER,
+ etWATError = EVENTTYPE_WAT_ERROR,
+ };
+
+ typedef std::vector<Contact*> ContactList;
+ typedef std::vector<const Contact*> ContactListC;
+ typedef std::pair<ext::string, ext::string> ConflictingFile; // (desired, temp)
+ typedef std::list<ConflictingFile> ConflictingFiles;
+ typedef std::map<Canvas::Digest, ext::string> ImageMap;
+
+private:
+ static bool m_bRunning;
+
+private:
+ // settings and the like
+ Settings m_Settings;
+ Settings::CharMapper m_CharMapper;
+
+ // handles for windows and synchronisation
+ HINSTANCE m_hInst;
+ HWND m_hWndProgress;
+ HANDLE m_hThreadPushEvent;
+ HANDLE m_hCancelEvent;
+ InvocationSource m_InvokedFrom;
+
+ // list of contacts
+ ContactList m_Contacts;
+
+ // special 'contacts': omitted, totals
+ Contact* m_pTotals;
+ Contact* m_pOmitted;
+
+ // did we really omit something
+ bool m_bActuallyOmitted;
+
+ // start time for statistics
+ DWORD m_TimeStarted;
+ DWORD m_MSecStarted;
+
+ // minimum/maximum date/time to include
+ DWORD m_TimeMin;
+ DWORD m_TimeMax;
+
+ // error processing and the like
+ ext::string m_ErrorText;
+
+ // column management
+ int m_nNextSlot;
+ std::vector<Column*> m_ActiveCols;
+ std::vector<Column*> m_AcquireCols;
+ std::vector<Column*> m_TransformCols;
+
+ // file management
+ ext::string m_TempPath;
+ ext::string m_OutputPath;
+ ext::string m_OutputFile;
+ ext::string m_OutputPrefix;
+ ConflictingFiles m_ConflictingFiles;
+ int m_nLastFileNr;
+
+ // PNG management
+ ImageMap m_Images;
+
+ // first/last message
+ bool m_bHistoryTimeAvailable;
+ DWORD m_nFirstTime;
+ DWORD m_nLastTime;
+
+ // misc data
+ DWORD m_AverageMinTime;
+
+private:
+ // contact handling
+ void prepareColumns();
+ void prepareContactData(Contact& contact);
+ void freeContactData(Contact& contact);
+ void mergeContactData(Contact& contact, const Contact& include);
+ void transformContactData(Contact& contact);
+ Contact& addContact(const ext::string& nick, const ext::string& protoDisplayName, const ext::string& groupName, int nSources);
+
+ // misc routines
+ DWORD getTimeStarted() { return m_TimeStarted; }
+ bool shouldTerminate() { return (WaitForSingleObject(m_hCancelEvent, 0) == WAIT_OBJECT_0) || (bool_(mu::system::terminated())); }
+ void handleAddMessage(Contact& contact, Message& msg);
+ void handleAddChat(Contact& contact, bool bOutgoing, DWORD localTimestampStarted, DWORD duration);
+
+ // progress dialog handling
+ static BOOL CALLBACK staticProgressProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ void setProgressMax(bool bSub, int max);
+ void setProgressLabel(bool bSub, const ext::string& label);
+ void stepProgress(bool bSub, int step = 1);
+ static BOOL CALLBACK staticConflictProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+ // statistics creation steps
+ bool stepInit();
+ bool stepReadDB();
+ bool stepRemoveContacts();
+ bool stepSortContacts();
+ bool stepPreOmitContacts();
+ bool stepOmitContacts();
+ bool stepCalcTotals();
+ bool stepPostOmitContacts();
+ bool stepTransformData();
+ bool stepWriteHTML();
+
+ // private constructor & main statistic creation routine
+ explicit Statistic(const Settings& settings, InvocationSource invokedFrom, HINSTANCE hInst);
+ bool createStatistics();
+ bool createStatisticsSteps();
+ static DWORD WINAPI threadProc(LPVOID lpParameter);
+ static DWORD WINAPI threadProcSteps(LPVOID lpParameter);
+
+public:
+ ~Statistic();
+
+public:
+ static void run(const Settings& settings, InvocationSource invokedFrom, HINSTANCE hInst, HWND hWndParent = NULL);
+
+ int countContacts() const { return m_Contacts.size(); }
+ const Contact& getContact(int index) const;
+ const Contact& getTotals() const { assert(m_pTotals); return *m_pTotals; }
+ const Contact& getOmitted() const { assert(m_pOmitted); return *m_pOmitted; }
+ bool hasTotals() const { return (m_pTotals != NULL) && m_Settings.m_CalcTotals; } // MEMO: only makes sense after 'calc totals'-step
+ bool hasOmitted() const { return (m_pOmitted != NULL) && m_Settings.m_OmitContacts && m_Settings.m_OmittedInExtraRow && m_bActuallyOmitted; } // MEMO: only makes sense after 'omit'-step
+ DWORD getFirstTime(); // MEMO: only makes sense after 'calc totals'-step
+ DWORD getLastTime(); // MEMO: only makes sense after 'calc totals'-step
+ DWORD getHistoryTime(); // MEMO: only makes sense after 'calc totals'-step
+ DWORD getAverageMinTime() { return m_AverageMinTime; }
+
+ // file management
+ ext::string createFile(const ext::string& desiredName);
+ bool newFile(const mu_text* fileExt, ext::string& writeFile, ext::string& finalURL);
+ bool newFilePNG(ext::string& writeFile, ext::string& finalURL) { return newFile(muT(".png"), writeFile, finalURL); }
+ bool newFilePNG(Canvas& canvas, ext::string& finalURL);
+};
+
+#endif // HISTORYSTATS_GUARD_STATISTIC_H
\ No newline at end of file |