• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiond556e315ce8bedd22d9663f13b0c06c0253716e4 (tree)
Time2012-02-22 23:27:26
Authorqwerty2501 <riot313@gmai...>
Commiterqwerty2501

Log Message

Safari対応

Change Summary

Incremental Difference

--- a/include/qwerty/windebuger.h
+++ b/include/qwerty/windebuger.h
@@ -671,7 +671,7 @@ static VOID DebugOutW(LPCWSTR fileName,LPCWSTR functionName,UINT lineNo, UINT mo
671671 }
672672
673673
674-static VOID DebugOutMB(UINT codePage,LPSTR fileName,LPSTR functionName,UINT lineNo,UINT mode,UINT infoFlag,LPSTR pszFormat, ...){
674+static VOID DebugOutMB(UINT codePage,LPSTR fileName,LPSTR functionName,UINT lineNo,UINT mode,UINT infoFlag,LPCSTR pszFormat, ...){
675675
676676
677677 LPSTR szFormat = mode & LINEFEAD__DEBUGER__ ? "%s%s%s%s\r\n" : "%s%s%s%s";
Binary files a/nlite.suo and b/nlite.suo differ
--- a/nlite/Resource.h
+++ b/nlite/Resource.h
@@ -35,3 +35,5 @@
3535 #define IDR_COMMAND6 40005
3636 #define IDC_RADIO_CHROME 40006
3737 #define IDC_RADIO_IECM 40009
38+#define IDC_RADIO_SAFARI 40012
39+#define IDC_RADIO_OPERA 40013
--- a/nlite/nlite.rc
+++ b/nlite/nlite.rc
@@ -63,18 +63,20 @@ IDC_NLITE MENU
6363 // Dialog resources
6464 //
6565 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
66-IDD_DIALOG_BROWSERTYPE DIALOG 0, 0, 123, 110
66+IDD_DIALOG_BROWSERTYPE DIALOG 0, 0, 193, 159
6767 STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
6868 CAPTION "クッキーの設定"
6969 FONT 8, "Ms Shell Dlg"
7070 {
71- AUTORADIOBUTTON "IE", IDC_RADIO_IE, 30, 29, 22, 8
72- AUTORADIOBUTTON "FireFox", IDC_RADIO_FIREFOX, 30, 45, 39, 8
73- AUTORADIOBUTTON "GoogleChrome", IDC_RADIO_CHROME, 30, 61, 62, 8
74- AUTORADIOBUTTON "IEコンポーネント", IDC_RADIO_IECM, 30, 76, 61, 8
75- PUSHBUTTON "OK", IDC_BUTTON_COOKIE_OK, 21, 91, 38, 14
76- PUSHBUTTON "キャンセル", IDCANCEL, 63, 91, 33, 14
71+ AUTORADIOBUTTON "IE", IDC_RADIO_IE, 61, 29, 22, 8
72+ AUTORADIOBUTTON "FireFox", IDC_RADIO_FIREFOX, 61, 45, 39, 8
73+ AUTORADIOBUTTON "GoogleChrome", IDC_RADIO_CHROME, 61, 61, 62, 8
74+ AUTORADIOBUTTON "IEコンポーネント", IDC_RADIO_IECM, 60, 77, 61, 8
75+ PUSHBUTTON "OK", IDC_BUTTON_COOKIE_OK, 40, 136, 38, 14
76+ PUSHBUTTON "キャンセル", IDCANCEL, 105, 137, 33, 14
7777 LTEXT "普段使用しているブラウザを指定してください", IDC_STATIC, 21, 6, 82, 22, SS_LEFT
78+ AUTORADIOBUTTON "Safari", IDC_RADIO_SAFARI, 60, 94, 33, 8
79+ AUTORADIOBUTTON "Opera", IDC_RADIO_OPERA, 60, 111, 35, 8
7880 }
7981
8082
--- a/nlite/nlite_mainframe.cpp
+++ b/nlite/nlite_mainframe.cpp
@@ -307,9 +307,13 @@ VOID CNliteMainFrame::OnCookie(UINT uNotifyCode,int nID,HWND hWndCtl){
307307 nliteProperty.CookieSetting();
308308 }
309309
310+ try {
311+ nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
312+ } catch(NLIBException &e){
310313
311- nicoVideoAuth.SetBrowserType(nliteProperty.gp.browserType);
314+ MessageBox(e.what(),TEXT("クッキー取得失敗"),MB_OK | MB_ICONERROR);
312315
316+ }
313317
314318
315319 }
--- a/nlite/nlite_nlib.cpp
+++ b/nlite/nlite_nlib.cpp
@@ -32,7 +32,7 @@ VOID CNicoVideoAuth::SetBrowserType(BROWSERTYPE bt){
3232 throw NLIBException(TEXT("ニコニコ動画認証情報取得に失敗しました"),rslt,__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
3333 }
3434
35- InternetSetOption(0, INTERNET_OPTION_END_BROWSER_SESSION, NULL, 0);
35+ return;
3636 }
3737
3838
--- a/nlite/nlite_propertyWindow.cpp
+++ b/nlite/nlite_propertyWindow.cpp
@@ -36,6 +36,18 @@ BOOL CCookieSettingWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam){
3636
3737 break;
3838
39+ case BT_SAFARI:
40+
41+ radio = GetDlgItem(IDC_RADIO_SAFARI);
42+ break;
43+
44+
45+ case BT_OPERA:
46+
47+ radio = GetDlgItem(IDC_RADIO_OPERA);
48+
49+ break;
50+
3951 default:
4052 goto skip;
4153 }
@@ -51,32 +63,41 @@ VOID CCookieSettingWindow::OnOK(UINT uNotifyCode, int nID, CWindow wndCtl){
5163 CButton firefoxRadio = GetDlgItem(IDC_RADIO_FIREFOX);
5264 CButton chromeRadio = GetDlgItem(IDC_RADIO_CHROME);
5365 CButton iecmRadio = GetDlgItem(IDC_RADIO_IECM);
66+ CButton safariRadio = GetDlgItem(IDC_RADIO_SAFARI);
67+ CButton operaRadio = GetDlgItem(IDC_RADIO_OPERA);
5468
5569 if(ieRadio.GetCheck() == BST_CHECKED){
5670
5771 this->browserType = BT_INTERNET_EXPLORER;
72+
73+ }else if(firefoxRadio.GetCheck() == BST_CHECKED){
5874
59- }
75+ this->browserType = BT_FIRE_FOX;
6076
61- if(firefoxRadio.GetCheck() == BST_CHECKED){
77+ }else if(chromeRadio.GetCheck() == BST_CHECKED){
6278
63- this->browserType = BT_FIRE_FOX;
79+ this->browserType = BT_GOOGLE_CHROME;
6480
65- }
81+ }else if(iecmRadio.GetCheck() == BST_CHECKED){
6682
67- if(chromeRadio.GetCheck() == BST_CHECKED){
83+ this->browserType = BT_IE_COMPONENT;
6884
69- this->browserType = BT_GOOGLE_CHROME;
85+ }else if(safariRadio.GetCheck() == BST_CHECKED){
7086
71- }
87+ this->browserType = BT_SAFARI;
7288
73- if(iecmRadio.GetCheck() == BST_CHECKED){
89+ } else if(operaRadio.GetCheck() == BST_CHECKED){
7490
75- this->browserType = BT_IE_COMPONENT;
91+ this->browserType = BT_OPERA;
92+
93+ }else {
94+
95+ this->browserType = BT_NOSETTING;
7696
7797 }
7898
7999
100+
80101 EndDialog(nID);
81102 }
82103
--- a/shareCookie/shareCookie.c
+++ b/shareCookie/shareCookie.c
@@ -24,8 +24,11 @@ static sqlite3_stmt *googleChromeCookieStmt; //
2424 static CRITICAL_SECTION googleChromeCs; //グーグルクロームのクッキー取得用クリティカルセクション
2525
2626
27+static WCHAR safariCookiePath[_MAX_PATH]; //サファリのクッキーパス
2728
2829
30+typedef COOKIE_RESULT (*SelfParseCookieCallBack)(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein);
31+
2932 ///
3033 ///クロームとファイアフォックスの共通処理
3134 ///
@@ -34,6 +37,11 @@ static INLINE VOID cookieStepExec(sqlite3_stmt *stmt,LPWSTR cooki,SIZE_T bufSize
3437
3538
3639 ///
40+///自力で解析す場合の共通処理
41+///
42+static INLINE COOKIE_RESULT SelfParseCookie(LPCWSTR cookieFilePath,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein,SelfParseCookieCallBack callBack);
43+
44+///
3745 ///インターネットエクスプローラーのクッキーを取得
3846 ///
3947 static INLINE COOKIE_RESULT GetCookieInternetExplorer(LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein,BOOL isIE);
@@ -51,12 +59,12 @@ static INLINE COOKIE_RESULT GetCookieGoogleChrome(LPWSTR cookie,SIZE_T bufSize,
5159 ///
5260 ///オペラのクッキーを取得
5361 ///
54-static INLINE COOKIE_RESULT GetCookieOpera(LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein);
62+static INLINE COOKIE_RESULT GetCookieOpera(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein);
5563
5664 ///
5765 ///サファリのクッキーを取得
5866 ///
59-static INLINE COOKIE_RESULT GetCookieSafari(LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein);
67+static INLINE COOKIE_RESULT GetCookieSafari(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookie,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein);
6068
6169 #define FIREFOX_GET_COOKIE_SQL "SELECT a.name, a.value FROM moz_cookies a WHERE a.name = ?1 AND a.baseDomain = ?2 " //ファイアフォックスクッキー取得用SQL
6270
@@ -76,7 +84,7 @@ VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){
7684
7785
7886 LPWSTR index;
79-
87+
8088
8189 wcscpy(fireFoxProfilesPath,appDataPath);
8290 wcscat(fireFoxProfilesPath,L"Mozilla\\Firefox\\profiles.ini");
@@ -155,6 +163,12 @@ VOID InitializeShareCookie(LPCWSTR appDataPath,LPCWSTR localAppDataPath){
155163
156164 }
157165
166+
167+ //サファリの設定
168+
169+ wcscpy(safariCookiePath,appDataPath);
170+ wcscat(safariCookiePath,L"Apple Computer\\Safari\\Cookies\\Cookies.binarycookies");
171+
158172 return;
159173 }
160174
@@ -201,14 +215,13 @@ COOKIE_RESULT GetCookie(BROWSERTYPE browserType,LPWSTR cookie,SIZE_T bufSize, LP
201215 //オペラの場合
202216 case BT_OPERA:
203217
204-
205- return GetCookieOpera(cookie,bufSize,key,domein);
218+ return SelfParseCookie(NULL,cookie,bufSize,key,domein,GetCookieOpera);
219+
206220
207221 //サファリの場合
208222 case BT_SAFARI:
209-
210- return GetCookieSafari(cookie,bufSize,key,domein);
211-
223+ return SelfParseCookie(safariCookiePath,cookie,bufSize,key,domein,GetCookieSafari);
224+
212225
213226 //IEコンポーネントの場合
214227 case BT_IE_COMPONENT:
@@ -633,7 +646,9 @@ end:
633646 ///
634647 ///オペラのクッキーを取得
635648 ///
636-static INLINE COOKIE_RESULT GetCookieOpera(LPWSTR cookies,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){
649+static INLINE COOKIE_RESULT GetCookieOpera(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookies,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){
650+
651+
637652
638653 return COOKIE_ERR_DETAIL_NOTFOUND;
639654 }
@@ -641,10 +656,70 @@ static INLINE COOKIE_RESULT GetCookieOpera(LPWSTR cookies,SIZE_T bufSize, LPCWST
641656 ///
642657 ///サファリのクッキーを取得
643658 ///
644-static INLINE COOKIE_RESULT GetCookieSafari(LPWSTR cookies,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){
659+static INLINE COOKIE_RESULT GetCookieSafari(LPCSTR targetString,LPCSTR targetEndPointer,LPWSTR cookies,SIZE_T bufSize, LPCWSTR key,LPCWSTR domein){
660+ COOKIE_RESULT result = COOKIE_ERR_UNKNOWN;
661+ CHAR mb_key[_MAX_PATH] = "A";
662+ CHAR mb_domein[_MAX_PATH] = ".";
663+ LPCSTR cookiePointer;
664+ LPCSTR domeinPointer;
665+ SIZE_T mb_keyLen;
666+
667+ if(ARRAY_LENGTH(mb_key) < GetLenToMB(CP_THREAD_ACP,key) - 1){
668+
669+ goto keybuffbigerr;
645670
671+ } else if(ARRAY_LENGTH(mb_domein) - 1 < GetLenToMB(CP_THREAD_ACP,domein) ){
646672
647- return COOKIE_ERR_DETAIL_NOTFOUND;
673+ goto domeinbuffbigerr;
674+
675+ }
676+
677+ WideToMB(CP_THREAD_ACP,key,mb_key + 1,ARRAY_LENGTH(mb_key) - 1);
678+ WideToMB(CP_THREAD_ACP,domein,mb_domein + 1,ARRAY_LENGTH(mb_domein) - 1);
679+ mb_keyLen = strlen(mb_key);
680+
681+ for(;targetString < targetEndPointer;targetString += strlen(targetString) + 1){
682+
683+ if(strstr(targetString,mb_key) != NULL){
684+
685+ cookiePointer = targetString + strlen(targetString) + 1;
686+ domeinPointer = cookiePointer + strlen(cookiePointer) + 1;
687+
688+ if(strcmp(mb_domein,domeinPointer) == 0){
689+
690+ if(((INT_PTR)bufSize) < GetLenToWide(CP_THREAD_ACP,cookiePointer) + wcslen(key) + 1){
691+
692+ goto cookiebuffbigerr;
693+ }
694+ wcscpy(cookies,key);
695+ cookies += wcslen(cookies);
696+ cookies[0] = L'=';
697+ cookies++;
698+
699+ MBToWide(CP_THREAD_ACP,cookiePointer,cookies,bufSize);
700+ result = COOKIE_ERR_OK;
701+ }
702+ }
703+
704+ }
705+
706+end:
707+
708+
709+ return result;
710+
711+
712+keybuffbigerr:
713+ result = COOKIE_ERR_DETAIL_URL_TOOBIG;
714+ goto end;
715+
716+domeinbuffbigerr:
717+ result = COOKIE_ERR_DETAIL_DOMEIN_TOOBIG;
718+ goto end;
719+
720+cookiebuffbigerr:
721+ result = COOKIEERR_DETAIL_RESULT_TOOBIG;
722+ goto end;
648723 }
649724
650725 ///
@@ -741,4 +816,41 @@ static INLINE VOID cookieStepExec(sqlite3_stmt *stmt,LPWSTR cookie,SIZE_T bufSiz
741816 return;
742817
743818
819+}
820+
821+
822+static COOKIE_RESULT SelfParseCookie(LPCWSTR cookieFilePath,LPWSTR cookie,SIZE_T bufSize,LPCWSTR key,LPCWSTR domein,SelfParseCookieCallBack callBack){
823+
824+ COOKIE_RESULT result = COOKIE_ERR_UNKNOWN;
825+
826+ HANDLE hCookieFile = CreateFile(cookieFilePath,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
827+ if(hCookieFile == INVALID_HANDLE_VALUE ){
828+
829+ goto fileopenerr;
830+ }
831+ {
832+ DWORD readSize;
833+ DWORD highSize;
834+ DWORD lowSize = GetFileSize(hCookieFile,&highSize);
835+ SIZE_T bufferSize = MAKELONG(lowSize,highSize);
836+ LPSTR buffer = (LPSTR)malloc(bufferSize);
837+
838+ ReadFile(hCookieFile,buffer,bufferSize,&readSize,NULL);
839+
840+
841+
842+
843+ result = callBack(buffer,buffer + (bufferSize / sizeof(CHAR)),cookie,bufSize,key,domein);
844+ free(buffer);
845+ }
846+
847+end:
848+
849+ CloseHandle(hCookieFile);
850+
851+ return result;
852+
853+fileopenerr:
854+ result = COOKIE_ERR_OPEN_FAILED;
855+ goto end;
744856 }
\ No newline at end of file
--- a/shareCookie/shareCookie.h
+++ b/shareCookie/shareCookie.h
@@ -84,8 +84,11 @@ extern COOKIE_RESULT GetCookie(BROWSERTYPE browserType,LPWSTR cookie,SIZE_T bufS
8484 ///未定義のブラウザタイプが設定された
8585 #define COOKIE_ERR_UNDEFINED_BROWSERTYPE ((COOKIE_RESULT) 11)
8686
87+///クッキーファイルを開くことが出来なかった
88+#define COOKIE_ERR_OPEN_FAILED ((COOKIE_RESULT) 12)
8789
88-
90+///ドメイン文字列の長さが長すぎる
91+#define COOKIE_ERR_DETAIL_DOMEIN_TOOBIG ((COOKIE_RESULT) 13)
8992
9093
9194
--- a/speaker/open_jtalk_core.cpp
+++ b/speaker/open_jtalk_core.cpp
@@ -108,6 +108,7 @@ void COpenJtalkCore::Load( const TChar_P in_voiceDataDir,const TChar_P in_dictin
108108
109109 void COpenJtalkCore::Synthesis( const TChar_P txt, FILE * wavfp, FILE * logfp){
110110 CStringA txtA(txt);
111+ idumpln_mb(CP_THREAD_ACP,"synthesis:%s",(LPCSTR)txtA);
111112 ::OpenJTalk_synthesis(&this->openJtalk_internal,(Char_P)(const char*)txtA,wavfp,logfp);
112113 }
113114
--- a/speaker/speaker.vcxproj
+++ b/speaker/speaker.vcxproj
@@ -38,10 +38,10 @@
3838 </ImportGroup>
3939 <PropertyGroup Label="UserMacros" />
4040 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
41- <IncludePath>$(solutiondir)open_jtalk_lib;$(IncludePath)</IncludePath>
41+ <IncludePath>$(solutiondir)open_jtalk_lib;$(solutiondir)include;$(IncludePath)</IncludePath>
4242 </PropertyGroup>
4343 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
44- <IncludePath>$(solutiondir)open_jtalk_lib;$(IncludePath)</IncludePath>
44+ <IncludePath>$(solutiondir)open_jtalk_lib;$(solutiondir)include;$(IncludePath)</IncludePath>
4545 </PropertyGroup>
4646 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4747 <ClCompile>
--- a/speaker/speaker_include.h
+++ b/speaker/speaker_include.h
@@ -1,7 +1,7 @@
11 #pragma once
22
33 #include <open_jtalk_lib.h>
4-
4+#include <qwerty\windebuger.h>
55
66 #include "speaker_define.h"
77 #include "speaker.h"
--- a/speaker/stdafx.h
+++ b/speaker/stdafx.h
@@ -6,7 +6,9 @@
66 #pragma once
77
88 #include "targetver.h"
9-
9+#define _CRT_SECURE_NO_WARNINGS 1 //vc++のおせっかいな警告を消す
10+#define _CRT_NON_CONFORMING_SWPRINTFS 1 //vc++のおせっかいな警告を消す
11+#define WINDEBUGER_NOPRINTING //デバッグ出力をコンソールに表示したくない場合定義する
1012 #define WIN32_LEAN_AND_MEAN // Windows ヘッダーから使用されていない部分を除外します。
1113
1214