3 * Implementation of a finder menu plugin for git-cheetah
5 * This implements the COM interface for the finder plugin
7 * Copyright (C) Heiko Voigt, 2009
9 * inspired by an example from Brent Simmons
10 * brent@ranchero.com, http://macte.ch/kmyXM
14 #include "../common/git-compat-util.h"
15 #include "../common/strbuf.h"
16 #include "../common/debug.h"
17 #include "../common/menuengine.h"
18 #include "../common/cheetahmenu.h"
23 void *create_instance(CFAllocatorRef a
, CFUUIDRef id
);
24 static HRESULT
query_interface(void *me
, REFIID id
, LPVOID
*ret
);
25 static ULONG
retain(void *me
);
26 static ULONG
release(void *me
);
28 static ContextualMenuInterfaceStruct plugin_virtual_table
= {
34 /* Context Menu Interface */
40 void *create_instance(CFAllocatorRef a
, CFUUIDRef id
)
42 struct plugin_data
*me
;
44 if (!CFEqual(id
, kContextualMenuTypeID
))
47 CFPlugInAddInstanceForFactory(myUUID
);
49 me
= (struct plugin_data
*) malloc(sizeof(struct plugin_data
));
50 memset(me
, 0, sizeof(struct plugin_data
));
52 me
->virtual_table
= &plugin_virtual_table
;
53 me
->id
= CFRetain(myUUID
);
59 static HRESULT
query_interface(void *_me
, REFIID id
, LPVOID
*ret
)
61 struct plugin_data
*me
= _me
;
62 Boolean interface_supported
= false;
63 CFUUIDRef query_id
= CFUUIDCreateFromUUIDBytes(NULL
, id
);
65 if (CFEqual(query_id
, kContextualMenuInterfaceID
))
66 interface_supported
= true;
68 if (CFEqual(query_id
, IUnknownUUID
))
69 interface_supported
= true;
73 if (!interface_supported
) {
84 static ULONG
retain(void *_me
)
86 struct plugin_data
*me
= _me
;
87 return ++(me
->num_ref
);
90 static ULONG
release(void *_me
)
92 struct plugin_data
*me
= _me
;
99 CFPlugInRemoveInstanceForFactory(me
->id
);