#pragma once #include #include"protocol.h" #include #include using namespace std; #define SHOW_LOCAL_HIDE 0 #define SHOW_LOCAL_SHOW 1 #define SHOW_LOCAL_SHOW_SEND 2 class Configuration { private: Configuration(void); ~Configuration(void); static Configuration *config; TCHAR configFile[128]; bool isPlaySound; bool isFixedPath; DWORD showLocal; wstring dir; wstring musicDir; wstring videoDir; wstring bookDir; wstring photoDir; wstring musicExt; wstring photoExt; wstring bookExt; wstring videoExt; wstring nickName; wstring broadcastAddress; bool IsMatch(wstring& fileName, wstring& extList); inline wstring& PreparePath(wstring &dir) { wstring::reverse_iterator it = dir.rbegin(); if(!(*it == (WCHAR)'\\' || *it == (WCHAR)'/')) { dir.push_back('\\'); } return dir; } public: inline DWORD GetShowLocal(){ return showLocal;} inline void SetShowLocal(DWORD showLocal) { this->showLocal = showLocal; } inline bool IsPlaySound(){ return isPlaySound; } inline void SetPlaySound(bool isPlaySound ) { this->isPlaySound = isPlaySound; } inline bool IsFixedPath(){ return isFixedPath; } inline void SetFixedPath(bool isFixedPath ) { this->isFixedPath = isFixedPath; } inline wstring& Dir() { return dir; } inline void SetDir(wstring& dir) { this->dir = PreparePath(dir); } inline wstring& MusicDir() { return musicDir; } inline void SetMusicDir(wstring& musicDir) { this->musicDir = PreparePath(musicDir); } inline wstring& VideoDir() { return videoDir; } inline void SetVideoDir(wstring& videoDir) { this->videoDir = PreparePath(videoDir); } inline wstring& BookDir() { return bookDir; } inline void SetBookDir(wstring& bookDir) { this->bookDir = PreparePath(bookDir); } inline wstring& PhotoDir() { return photoDir; } inline void SetPhotoDir(wstring& photoDir) { this->photoDir = PreparePath(photoDir); } inline wstring& MusicExt() { return musicExt; } inline void SetMusicExt(wstring& musicExt) { this->musicExt = musicExt; } inline wstring& PhotoExt() { return photoExt; } inline void SetPhotoExt(wstring& photoExt) { this->photoExt = photoExt; } inline wstring& BookExt() { return bookExt; } inline void SetBookExt(wstring& bookExt) { this->bookExt = bookExt; } inline wstring& VideoExt() { return videoExt; } inline void SetVideoExt(wstring& videoExt) { this->videoExt = videoExt; } inline wstring& BroadcastAddress() { return broadcastAddress;} inline void SetBroadcastAddress(wstring& broadcastAddress) { this->broadcastAddress = broadcastAddress; } inline wstring& NickName() { return nickName; } inline void SetNickName(wstring& nickName) { this->nickName = nickName; } BOOL Save() ; static Configuration *GetInstance() { return config; } class AutoGC { public: AutoGC() { config = new Configuration(); } ~AutoGC() { if(Configuration::config != NULL) { delete config; } } }; static AutoGC autoGC; void GetSmartPath(wstring& fileName, wstring& path); void GetBroadcastList(vector& broadcastList); }; //Configuration::AutoGC Configuration::autoGC;