Advertisement
Guest User

Untitled

a guest
Apr 4th, 2013
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.03 KB | None | 0 0
  1. diff --git a/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.cpp b/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.cpp
  2. index 05b6b44..f6cefd5 100644
  3. --- a/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.cpp
  4. +++ b/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.cpp
  5. @@ -7,6 +7,12 @@
  6.  CRecInfoDBManager::CRecInfoDBManager(void)
  7.  {
  8.     this->lockEvent = _CreateEvent(FALSE, TRUE, NULL);
  9. +
  10. +   ::CoInitialize( NULL );
  11. +   HRESULT hr=regExp.CreateInstance(CLSID_RegExp);
  12. +   if(FAILED(hr)){
  13. +       regExp = NULL;
  14. +   }
  15.  }
  16.  
  17.  
  18. @@ -19,6 +25,12 @@ CRecInfoDBManager::~CRecInfoDBManager(void)
  19.         CloseHandle(this->lockEvent);
  20.         this->lockEvent = NULL;
  21.     }
  22. +
  23. +   if( regExp != NULL ){
  24. +       regExp.Release();
  25. +   }
  26. +
  27. +   ::CoUninitialize();
  28.  }
  29.  
  30.  BOOL CRecInfoDBManager::Lock(LPCWSTR log, DWORD timeOut)
  31. @@ -116,10 +128,17 @@ void CRecInfoDBManager::CreateKeyMap()
  32.     }
  33.     this->titleMap.clear();
  34.  
  35. +   wstring iniAppPath = L"";
  36. +   GetModuleIniPath(iniAppPath);
  37. +   WCHAR buff[1024] = L"";
  38. +   GetPrivateProfileString(L"SET", L"RecInfo2RegExp", L"", buff, 1024, iniAppPath.c_str());
  39. +   wstring strReg = buff;
  40. +
  41.     for( size_t i=0 ;i<this->recInfoList.size(); i++ ){
  42.         wstring title = L"";
  43.         if( this->recInfoList[i]->shortInfo != NULL ){
  44.             title = this->recInfoList[i]->shortInfo->event_name;
  45. +           ReplaceRegExp(title, strReg, L"");
  46.         }
  47.         map<wstring, RECINFO_LIST_ITEM*>::iterator itrTitle;
  48.         RECINFO_LIST_ITEM* itemTitle = NULL;
  49. @@ -226,9 +245,16 @@ BOOL CRecInfoDBManager::IsFindTitleInfo(EPGDB_EVENT_INFO* info, WORD chkDay)
  50.     if( Lock() == FALSE ) return FALSE;
  51.     BOOL ret = FALSE;
  52.  
  53. +   wstring iniAppPath = L"";
  54. +   GetModuleIniPath(iniAppPath);
  55. +   WCHAR buff[1024] = L"";
  56. +   GetPrivateProfileString(L"SET", L"RecInfo2RegExp", L"", buff, 1024, iniAppPath.c_str());
  57. +   wstring strReg = buff;
  58. +
  59.     wstring title = L"";
  60.     if( info->shortInfo != NULL ){
  61.         title = info->shortInfo->event_name;
  62. +       ReplaceRegExp(title, strReg, L"");
  63.     }
  64.     __int64 weekSec = chkDay*24*60*60;
  65.     weekSec *= I64_1SEC;
  66. @@ -256,3 +282,19 @@ BOOL CRecInfoDBManager::IsFindTitleInfo(EPGDB_EVENT_INFO* info, WORD chkDay)
  67.     return ret;
  68.  }
  69.  
  70. +void CRecInfoDBManager::ReplaceRegExp(wstring &strBuff, wstring strReg, wstring strNew)
  71. +{
  72. +   if( this->regExp != NULL && strBuff.size() > 0 && strReg.size() > 0 ){
  73. +       try{
  74. +           _bstr_t target( strBuff.c_str() );
  75. +           _bstr_t pattern( strReg.c_str() );
  76. +           _bstr_t replace( strNew.c_str() );
  77. +
  78. +           this->regExp->PutGlobal( VARIANT_TRUE );
  79. +           this->regExp->PutPattern( pattern );
  80. +
  81. +           strBuff = (wstring)this->regExp->Replace( target, replace );
  82. +       }catch(...){
  83. +       }
  84. +   }
  85. +}
  86. diff --git a/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.h b/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.h
  87. index bc768e3..bbd91e9 100644
  88. --- a/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.h
  89. +++ b/EpgTimerSrv/EpgTimerSrv/RecInfoDBManager.h
  90. @@ -5,6 +5,8 @@
  91.  #include "../../Common/StringUtil.h"
  92.  #include "../../Common/PathUtil.h"
  93.  
  94. +#import "RegExp.tlb" no_namespace named_guids
  95. +
  96.  class CRecInfoDBManager
  97.  {
  98.  public:
  99. @@ -17,6 +19,7 @@ public:
  100.     void AddInfo(EPGDB_EVENT_INFO* info);
  101.  
  102.     BOOL IsFindTitleInfo(EPGDB_EVENT_INFO* info, WORD chkDay);
  103. +   void ReplaceRegExp(wstring &strBuff, wstring strReg, wstring strNew);
  104.  protected:
  105.     typedef struct _RECINFO_LIST_ITEM{
  106.         vector<EPGDB_EVENT_INFO*> infoList;
  107. @@ -26,6 +29,8 @@ protected:
  108.  
  109.     vector<EPGDB_EVENT_INFO*> recInfoList;
  110.     map<wstring, RECINFO_LIST_ITEM*> titleMap;
  111. +
  112. +   IRegExpPtr regExp;
  113.  protected:
  114.     //PublicAPI排他制御用
  115.     BOOL Lock(LPCWSTR log = NULL, DWORD timeOut = 60*1000);
  116. diff --git a/Readme_EpgTimer.txt b/Readme_EpgTimer.txt
  117. index 035b25d..c63c3b7 100644
  118. --- a/Readme_EpgTimer.txt
  119. +++ b/Readme_EpgTimer.txt
  120. @@ -1215,6 +1215,8 @@ $Result$ 
  121.  
  122.  誤判定で無効になる場合は、自動予約登録の条件を変更してください。
  123.  無効以外に変更しても、再チェックで無効にされます。
  124. +自動予約登録で登録された予約以外は無効にされないため、一旦予約を削除して手動で登
  125. +録しなおせば回避できます。
  126.  
  127.  ■Q&A■
  128.  ・なんで.Net Framework使うようになったの?
  129. @@ -1575,6 +1577,17 @@ ID
  130.   EpgTimerSrv.iniのSETにRecInfo2DropChkを追加することで数を変更可能です。
  131.   デフォルトは15となっています。
  132.  
  133. +■同一番組無効登録で番組名の比較の際に無視する文字列を指定する■
  134. + [][]などのついた番組名も同一番組として扱いたい場合に利用する
  135. + ことを想定したもの。
  136. + EpgTimerSrv.iniのSETにRecInfo2RegExpを追加することで指定可能です。
  137. + 文字列は正規表現として扱われ、動作としては、
  138. + 番組名から正規表現にマッチする部分を削除したものが同一番組名判定に
  139. + 使われます。
  140. + 例:
  141. + RecInfo2RegExp=¥[[再無生]¥]
  142. + ([][][]に対応)
  143. +
  144.  ■ブラウザから表示できるようにする■
  145.   使用前に一度EpgTimerの設定を開いてOKで閉じてください。動作に必要な情
  146.   報が保存されます。
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement