* tar xzf utvpn-src-unix-v101-7101-public-2010.06.27.tar.gz
[lab.git] / utvpn / utvpn-unix-v101-7101-public / src / Cedar / WinJumpList.cpp
diff --git a/utvpn/utvpn-unix-v101-7101-public/src/Cedar/WinJumpList.cpp b/utvpn/utvpn-unix-v101-7101-public/src/Cedar/WinJumpList.cpp
new file mode 100644 (file)
index 0000000..ecaf0eb
--- /dev/null
@@ -0,0 +1,440 @@
+// SoftEther UT-VPN SourceCode\r
+// \r
+// Copyright (C) 2004-2010 SoftEther Corporation.\r
+// Copyright (C) 2004-2010 University of Tsukuba, Japan.\r
+// Copyright (C) 2003-2010 Daiyuu Nobori.\r
+// All Rights Reserved.\r
+// \r
+// http://utvpn.tsukuba.ac.jp/\r
+// \r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// version 2 as published by the Free Software Foundation.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+// GNU General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU General Public License version 2\r
+// along with this program; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
+// \r
+// このファイルは GPL バージョン 2 ライセンスで公開されています。\r
+// 誰でもこのファイルの内容を複製、改変したり、改変したバージョンを再配布\r
+// することができます。ただし、原著作物を改変した場合は、原著作物の著作権表示\r
+// を除去することはできません。改変した著作物を配布する場合は、改変実施者の\r
+// 著作権表示を原著作物の著作権表示に付随して記載するようにしてください。\r
+// \r
+// この SoftEther UT-VPN オープンソース・プロジェクトは、日本国の\r
+// ソフトイーサ株式会社 (SoftEther Corporation, http://www.softether.co.jp/ )\r
+// および筑波大学 (University of Tsukuba, http://www.tsukuba.ac.jp/ ) によって\r
+// ホストされています。\r
+// 本プログラムの配布者は、本プログラムを、業としての利用以外のため、\r
+// および、試験または研究のために利用が行われることを想定して配布\r
+// しています。\r
+// SoftEther UT-VPN プロジェクトの Web サイトは http://utvpn.tsukuba.ac.jp/ に\r
+// あります。\r
+// 本ソフトウェアの不具合の修正、機能改良、セキュリティホールの修復などのコード\r
+// の改変を行った場合で、その成果物を SoftEther UT-VPN プロジェクトに提出して\r
+// いただける場合は、 http://utvpn.tsukuba.ac.jp/ までソースコードを送付して\r
+// ください。SoftEther UT-VPN プロジェクトの本体リリースまたはブランチリリース\r
+// に組み込みさせていただきます。\r
+// \r
+// GPL に基づいて原著作物が提供される本ソフトウェアの改良版を配布、販売する\r
+// 場合は、そのソースコードを GPL に基づいて誰にでも開示する義務が生じます。\r
+// \r
+// 本ソフトウェアに関連する著作権、特許権、商標権はソフトイーサ株式会社\r
+// (SoftEther Corporation) およびその他の著作権保持者が保有しています。\r
+// ソフトイーサ株式会社等はこれらの権利を放棄していません。本ソフトウェアの\r
+// 二次著作物を配布、販売する場合は、これらの権利を侵害しないようにご注意\r
+// ください。\r
+// \r
+// お願い: どのような通信ソフトウェアにも通常は必ず未発見の\r
+// セキュリティホールが潜んでいます。本ソースコードをご覧いただいた結果、\r
+// UT-VPN にセキュリティホールを発見された場合は、当該セキュリティホールの\r
+// 情報を不特定多数に開示される前に、必ず、ソフトイーサ株式会社\r
+// および脆弱性情報の届出を受け付ける公的機関まで通報いただき、\r
+// 公益保護にご協力いただきますようお願い申し上げます。\r
+// \r
+// ソフトイーサ株式会社は、当該セキュリティホールについて迅速に対処を\r
+// 行い、UT-VPN および UT-VPN に関連するソフトウェアのユーザー・顧客\r
+// を保護するための努力を行います。\r
+// \r
+// ソフトイーサへの届出先: http://www.softether.co.jp/jp/contact/\r
+// 日本国内の脆弱性情報届出受付公的機関:\r
+//         独立行政法人 情報処理推進機構\r
+//         http://www.ipa.go.jp/security/vuln/report/\r
+// \r
+// 上記各事項について不明な点は、ソフトイーサ株式会社までご連絡ください。\r
+// 連絡先: http://www.softether.co.jp/jp/contact/\r
+\r
+// -----------------------------------------------\r
+// [ChangeLog]\r
+// 2010.05.20\r
+//  新規リリース by SoftEther\r
+// -----------------------------------------------\r
+\r
+// WinJumpList.cpp\r
+// Windows7用 ジャンプリスト ソースコード\r
+\r
+// Q. このソースコードだけ他と違ってコメントが少ないように見える。\r
+// A. はい。\r
+\r
+#ifdef WIN32\r
+\r
+//#define NTDDI_WIN7                          0x06010000\r
+//#define      _WIN32_WINNT    _WIN32_WINNT_VISTA\r
+//#define NTDDI_VERSION NTDDI_VISTA  // Specifies that the minimum required platform is Windows 7.\r
+#define WIN32_LEAN_AND_MEAN       // Exclude rarely-used stuff from Windows headers\r
+#define STRICT_TYPED_ITEMIDS      // Utilize strictly typed IDLists\r
+\r
+//#include <objectarray.h>\r
+#include <shobjidl.h>\r
+#include <propkey.h>\r
+#include <propvarutil.h>\r
+//#include <knownfolders.h>\r
+//#include <shlobj.h>\r
+\r
+\r
+#ifdef StrCpy\r
+#undef StrCpy\r
+#endif\r
+\r
+#ifdef StrCat\r
+#undef StrCat\r
+#endif\r
+\r
+#ifdef StrCmp\r
+#undef StrCmp\r
+#endif\r
+\r
+\r
+#define        WIN32HTML_CPP\r
+\r
+//#define      _WIN32_WINNT            0x0502\r
+//#define      WINVER                          0x0502\r
+#include <winsock2.h>\r
+#include <windows.h>\r
+#include <wincrypt.h>\r
+#include <wininet.h>\r
+#include <comdef.h>\r
+#include <Mshtmhst.h>\r
+//#include <shlobj.h>\r
+#include <commctrl.h>\r
+#include <Dbghelp.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <wchar.h>\r
+#include <stdarg.h>\r
+#include <time.h>\r
+#include <errno.h>\r
+\r
+extern "C"\r
+{\r
+#include <Mayaqua/Mayaqua.h>\r
+#include <Cedar/Cedar.h>\r
+}\r
+#include "../PenCore/resource.h"\r
+\r
+extern "C"\r
+{\r
+\r
+       //////////////////////////////////////////////////////////////////////////\r
+       //JumpList\r
+       // 注意: このあたりのコードは Win32 ヘッダファイル等からコピーした部分がある。\r
+       //       ただしコピーしたのは単純な部分のみであり、創造的かつ複雑な部分ではないので\r
+       //       GPL のコードの一部としてペーストしてあっても問題にはならないものと解釈\r
+       //       している。\r
+\r
+       #define CREATE_PROPERTYKEY(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) { { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }, pid }\r
+\r
+\r
+       JL_HRESULT JL_CreateCustomDestinationList(JL_PCustomDestinationList* poc, wchar_t* appID)\r
+       {\r
+               ICustomDestinationList *pcdl;\r
+\r
+               //CLSID_DestinationList = 6332DEBF-87B5-4670-90C0-5E57-B408-A49E\r
+\r
+               GUID destList;\r
+\r
+               destList.Data1 = 2012286192;\r
+               destList.Data2 = 15797;\r
+               destList.Data3 = 18790;\r
+\r
+               destList.Data4[0] = 181;\r
+               destList.Data4[1] = 32;\r
+               destList.Data4[2] = 183;\r
+               destList.Data4[3] = 197;\r
+               destList.Data4[4] = 79;\r
+               destList.Data4[5] = 211;\r
+               destList.Data4[6] = 94;\r
+               destList.Data4[7] = 214;\r
+\r
+               HRESULT hr = CoCreateInstance(destList, \r
+                       NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pcdl));\r
+\r
+               if (SUCCEEDED(hr))\r
+               {\r
+                       pcdl->SetAppID(appID);\r
+                       (*poc) = (void*)pcdl;\r
+               }\r
+               else\r
+               {\r
+                       (*poc) = NULL;\r
+               }\r
+\r
+               return hr;\r
+       }\r
+\r
+       JL_HRESULT JL_ReleaseCustomDestinationList(JL_PCustomDestinationList poc)\r
+       {\r
+               ICustomDestinationList *pcdl = (ICustomDestinationList*)poc;\r
+               if(pcdl != NULL)\r
+               {\r
+                       pcdl->Release();\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+       JL_HRESULT JL_BeginList(JL_PCustomDestinationList poc, JL_PObjectArray* oaRemoved)\r
+       {\r
+               UINT cMinSlots;\r
+               IObjectArray *poaRemoved;\r
+\r
+               ICustomDestinationList *pcdl = (ICustomDestinationList*)poc;\r
+\r
+               HRESULT hr = pcdl->BeginList(&cMinSlots, IID_PPV_ARGS(&poaRemoved));\r
+\r
+               (*oaRemoved) = poaRemoved;\r
+\r
+               return hr;\r
+       }\r
+\r
+       JL_HRESULT JL_CommitList(JL_PCustomDestinationList cdl)\r
+       {\r
+               ICustomDestinationList *pcdl = (ICustomDestinationList*)cdl;\r
+\r
+               return pcdl->CommitList();\r
+       }\r
+\r
+       JL_HRESULT JL_CreateObjectCollection(JL_PObjectCollection* jpoc)\r
+       {\r
+\r
+               //CLSID_EnumerableObjectCollection = 2D3468C1-36A7-43B6-AC24-D3F0-2FD9-607A\r
+\r
+\r
+               GUID enumObjCol;\r
+\r
+               enumObjCol.Data1 = 758409409;\r
+               enumObjCol.Data2 = 13991;\r
+               enumObjCol.Data3 = 17334;\r
+\r
+               enumObjCol.Data4[0] = 172;\r
+               enumObjCol.Data4[1] = 36;\r
+               enumObjCol.Data4[2] = 211;\r
+               enumObjCol.Data4[3] = 240;\r
+               enumObjCol.Data4[4] = 47;\r
+               enumObjCol.Data4[5] = 217;\r
+               enumObjCol.Data4[6] = 96;\r
+               enumObjCol.Data4[7] = 122;\r
+\r
+               IObjectCollection *poc;\r
+               HRESULT hr = CoCreateInstance(enumObjCol,\r
+                       NULL, CLSCTX_INPROC, IID_PPV_ARGS(&poc));\r
+\r
+               if (SUCCEEDED(hr))\r
+               {\r
+                       (*jpoc) = poc;\r
+               }\r
+               else{\r
+                       (*jpoc) = NULL;\r
+               }\r
+               return hr;\r
+       }\r
+\r
+       JL_HRESULT JL_ReleaseObjectCollection(JL_PObjectCollection jpoc)\r
+       {\r
+               IObjectCollection *poc = (IObjectCollection *)jpoc;\r
+               if(poc != NULL)\r
+               {\r
+                       return poc->Release();\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+       JL_HRESULT JL_ObjectCollectionAddShellLink(JL_PObjectCollection jpoc, JL_PShellLink jpsl)\r
+       {\r
+               IObjectCollection *poc = (IObjectCollection *)jpoc;\r
+               IShellLink *psl = (IShellLink *) jpsl;\r
+\r
+               return poc->AddObject(psl);\r
+\r
+       }\r
+\r
+\r
+       JL_HRESULT JL_AddCategoryToList(JL_PCustomDestinationList jpcdl, \r
+               JL_PObjectCollection jpoc, \r
+               wchar_t* categoryName,\r
+               JL_PObjectArray jpoaRemoved)\r
+       {\r
+               ICustomDestinationList *pcdl = (ICustomDestinationList*)jpcdl;\r
+               IObjectCollection *poc = (IObjectCollection *)jpoc;\r
+                IObjectArray *poaRemoved = (IObjectArray*)jpoaRemoved;\r
+\r
+               IObjectArray *poa;\r
+               HRESULT hr = poc->QueryInterface(IID_PPV_ARGS(&poa));\r
+               if (SUCCEEDED(hr))\r
+               {\r
+               \r
+                       hr = pcdl->AppendCategory(categoryName, poa);\r
+                       poa->Release();\r
+\r
+                       if (SUCCEEDED(hr))\r
+                       {\r
+                       }\r
+                       else\r
+                       {\r
+                               Print("Failed AppendCategory\n");\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       Print("Failed QueryInterface\n");\r
+               }\r
+               \r
+\r
+               return hr;\r
+       }\r
+\r
+\r
+\r
+       JL_HRESULT JL_CreateShellLink(\r
+               wchar_t* pszPath, \r
+               wchar_t* pszArguments, \r
+               wchar_t* pszTitle, \r
+               wchar_t* iconLocation,\r
+               int iconIndex, \r
+               wchar_t* description, JL_PShellLink *ppsl)\r
+       {\r
+               IShellLinkW *psl;\r
+               HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl));\r
+               if (SUCCEEDED(hr))\r
+               {\r
+                       psl->SetPath(pszPath);\r
+                       psl->SetArguments(pszArguments);\r
+                       if(iconLocation != NULL)\r
+                       {\r
+                               psl->SetIconLocation(iconLocation,iconIndex);\r
+                       }\r
+\r
+                       if(description != NULL)\r
+                       {\r
+                               psl->SetDescription(description);\r
+                       }\r
+                               if (SUCCEEDED(hr))\r
+                               {\r
+                                       IPropertyStore *pps;\r
+                                       hr = psl->QueryInterface(IID_PPV_ARGS(&pps));\r
+                                       if (SUCCEEDED(hr))\r
+                                       {\r
+                                               PROPVARIANT propvar;\r
+                                               hr = InitPropVariantFromString(pszTitle, &propvar);\r
+                                               if (SUCCEEDED(hr))\r
+                                               {\r
+\r
+                                                       PROPERTYKEY pkey_title = \r
+                                                               CREATE_PROPERTYKEY(0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 2);\r
+\r
+                                                       hr = pps->SetValue(pkey_title, propvar);\r
+\r
+\r
+                                                       if (SUCCEEDED(hr))\r
+                                                       {\r
+                                                               hr = pps->Commit();\r
+                                                               if (SUCCEEDED(hr))\r
+                                                               {\r
+                                                                       IShellLink *tpsl;\r
+                                                                       hr = psl->QueryInterface(IID_PPV_ARGS(&tpsl));\r
+                                                                       (*ppsl) = tpsl;\r
+                                                               }\r
+                                                       }\r
+                                                       PropVariantClear(&propvar);\r
+                                               }\r
+                                               pps->Release();\r
+                                       }\r
+                               }\r
+                       psl->Release();\r
+               }\r
+               return hr;\r
+       }\r
+\r
+       JL_HRESULT JL_ReleaseShellLink(JL_PShellLink jpsl)\r
+       {\r
+               IShellLink *psl = (IShellLink *) jpsl;\r
+\r
+               if(psl != NULL)\r
+               {\r
+                       return psl->Release();\r
+               }\r
+\r
+               return 0;\r
+       }\r
+\r
+       JL_HRESULT JL_DeleteJumpList(JL_PCustomDestinationList jpcdl,wchar_t* appID)\r
+       {\r
+               ICustomDestinationList *pcdl = (ICustomDestinationList *)jpcdl;\r
+\r
+               HRESULT hr = pcdl->DeleteList(appID);\r
+\r
+\r
+               return hr;\r
+       }\r
+\r
+\r
+\r
+       //////////////////////////////////////////////////////////////////////////\r
+       //SetApplicationID for Windows 7\r
+       JL_HRESULT JL_SetCurrentProcessExplicitAppUserModelID(wchar_t* appID)\r
+       {\r
+#ifdef UNICODE\r
+               HMODULE hModule = LoadLibraryW( L"shell32.dll");\r
+#else\r
+               HMODULE hModule = LoadLibraryA( "shell32.dll");\r
+#endif\r
+               HRESULT (__stdcall *SetAppID) (PCWSTR);\r
+\r
+               if( hModule == NULL )\r
+               {\r
+                       Print("Not Found shell32.dll");\r
+               }\r
+               else\r
+               {\r
+                       SetAppID = (HRESULT (__stdcall *)(PCWSTR))\r
+                               GetProcAddress( hModule, "SetCurrentProcessExplicitAppUserModelID" );\r
+                       if( SetAppID != NULL )\r
+                       {\r
+                               FreeLibrary( hModule );\r
+                               return SetAppID(appID);\r
+                       }\r
+                       else\r
+                       {\r
+                               Print("Not Found SetCurrentProcessExplicitAppUserModelID");\r
+\r
+                       }\r
+\r
+                       FreeLibrary( hModule );\r
+               }\r
+               return 0;\r
+\r
+\r
+       }\r
+\r
+\r
+\r
+}\r
+\r
+#endif\r