2 #include "../common/cache.h"
7 #include "../common/menuengine.h"
9 #include "../common/debug.h"
10 #include "../common/systeminfo.h"
12 DWORD object_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 ULONG STDMETHODCALLTYPE
add_ref_git_data(struct git_data
*this_
)
24 return ++(this_
->count
);
27 ULONG STDMETHODCALLTYPE
release_git_data(struct git_data
*this_
)
29 if (--(this_
->count
) == 0) {
30 strbuf_release(&this_
->other_files
);
33 InterlockedDecrement(&object_count
);
39 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
;
55 add_ref_git_data(this_
);
59 STDMETHODIMP
initialize_git_data(struct git_data
*this_
,
61 LPDATAOBJECT data
, HKEY id
)
64 = {CF_HDROP
, NULL
, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
65 STGMEDIUM stg
= {TYMED_HGLOBAL
};
68 HRESULT result
= S_OK
;
70 /* if we can't find msysPath, don't even try to do anything else */
74 /* store the folder, if provided */
76 SHGetPathFromIDList(folder
, this_
->name
);
81 if (FAILED(data
->lpVtbl
->GetData(data
, &format
, &stg
)))
84 drop
= (HDROP
)GlobalLock(stg
.hGlobal
);
89 count
= DragQueryFile(drop
, 0xFFFFFFFF, NULL
, 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
);
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