Reset inheritable flag of debug log file git_shell_ext_debug.txt
[git-cheetah/kirill.git] / explorer / ext.c
blobd62ae7ee43a85955fa9166623633720f079adb3e
2 #include "../common/cache.h"
4 #include <shlobj.h>
5 #include <stdarg.h>
6 #include <tchar.h>
7 #include "../common/menuengine.h"
8 #include "ext.h"
9 #include "../common/debug.h"
10 #include "../common/systeminfo.h"
12 DWORD object_count = 0;
13 DWORD lock_count = 0;
16 * Standard methods for the IUnknown interface:
17 * add_ref, release, query_interface and initialize.
19 * Both of our COM objects contain pointers to the git_data object.
22 inline ULONG STDMETHODCALLTYPE add_ref_git_data(struct git_data *this_)
24 return ++(this_->count);
27 inline ULONG STDMETHODCALLTYPE release_git_data(struct git_data *this_)
29 if (--(this_->count) == 0) {
30 strbuf_release(&this_->other_files);
32 GlobalFree(this_);
33 InterlockedDecrement(&object_count);
34 return 0;
36 return this_->count;
39 inline STDMETHODIMP query_interface_git_data(struct git_data *this_,
40 REFIID iid, LPVOID FAR *pointer)
42 if (IsEqualIID(iid, &IID_git_shell_ext) ||
43 IsEqualIID(iid, &IID_IShellExtInit) ||
44 IsEqualIID(iid, &IID_IUnknown)) {
45 *pointer = &this_->shell_ext;
46 } else if (IsEqualIID(iid, &IID_git_menu) ||
47 IsEqualIID(iid, &IID_IContextMenu)) {
48 *pointer = &this_->menu;
49 } else if (IsEqualIID(iid, &IID_git_columns) ||
50 IsEqualIID(iid, &IID_IColumnProvider)) {
51 *pointer = &this_->columns;
52 } else
53 return E_NOINTERFACE;
55 add_ref_git_data(this_);
56 return NOERROR;
59 inline STDMETHODIMP initialize_git_data(struct git_data *this_,
60 LPCITEMIDLIST folder,
61 LPDATAOBJECT data, HKEY id)
63 FORMATETC format
64 = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
65 STGMEDIUM stg = {TYMED_HGLOBAL};
66 HDROP drop;
67 UINT count;
68 HRESULT result = S_OK;
70 /* if we can't find msysPath, don't even try to do anything else */
71 if (!git_path())
72 return E_NOTIMPL;
74 /* store the folder, if provided */
75 if (folder)
76 SHGetPathFromIDList(folder, this_->name);
78 if (!data)
79 return S_OK;
81 if (FAILED(data->lpVtbl->GetData(data, &format, &stg)))
82 return E_INVALIDARG;
84 drop = (HDROP)GlobalLock(stg.hGlobal);
86 if (!drop)
87 return E_INVALIDARG;
89 count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
91 if (count == 0)
92 result = E_INVALIDARG;
93 else if (!DragQueryFile(drop, 0, this_->name, sizeof(this_->name)))
94 result = E_INVALIDARG;
96 GlobalUnlock(stg.hGlobal);
97 ReleaseStgMedium(&stg);
99 return result;
103 * Define the shell extension.
105 * Its sole purpose is to be able to query_interface() the context menu.
107 DEFINE_STANDARD_METHODS(git_shell_ext)
109 struct git_shell_ext_virtual_table git_shell_ext_virtual_table = {
110 query_interface_git_shell_ext,
111 add_ref_git_shell_ext,
112 release_git_shell_ext,
113 initialize_git_shell_ext