00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "nsISupports.idl"
00028
00029 interface sbIDeviceControllerRegistrar;
00030
00034 [scriptable, uuid(3dc4e74e-104e-416f-ba1b-9c6685bc416f)]
00035 interface sbIDeviceMarshall : nsISupports
00036 {
00040 readonly attribute nsIDPtr id;
00041
00045 readonly attribute AString name;
00046
00051 void loadControllers(in sbIDeviceControllerRegistrar aRegistrar);
00052
00053 void beginMonitoring();
00054
00059 void stopMonitoring();
00060 };
00061
00062 %{C++
00063 #include "nsCOMPtr.h"
00064 #include "nsIComponentManager.h"
00065 #include "nsICategoryManager.h"
00066 #include "nsIServiceManager.h"
00067 #include "nsStringGlue.h"
00068 #include "nsXPCOMCID.h"
00069
00070 class nsIFile;
00071 struct nsModuleComponentInfo;
00072
00073 #define SB_DEVICE_MARSHALL_CATEGORY "songbird-device-marshall"
00074
00096 #define SB_DEVICE_MARSHALL_REGISTERSELF(_name) \
00097 \
00098 static NS_METHOD _name##RegisterSelf(nsIComponentManager* aCompMgr, \
00099 nsIFile* aPath, \
00100 const char* registryLocation, \
00101 const char* componentType, \
00102 const nsModuleComponentInfo* info); \
00103 \
00104 static NS_METHOD _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
00105 nsIFile* aPath, \
00106 const char* registryLocation, \
00107 const nsModuleComponentInfo* info)
00108
00112 #define SB_DEVICE_MARSHALL_REGISTERSELF_IMPL(_name) \
00113 \
00114 NS_METHOD \
00115 _name##RegisterSelf(nsIComponentManager* aCompMgr, \
00116 nsIFile* aPath, \
00117 const char* registryLocation, \
00118 const char* componentType, \
00119 const nsModuleComponentInfo* info) \
00120 { \
00121 nsresult rv; \
00122 nsCOMPtr<nsICategoryManager> catMan = \
00123 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
00124 NS_ENSURE_SUCCESS(rv, rv); \
00125 nsID id; \
00126 rv = this->GetIdInPlace(&id); \
00127 NS_ENSURE_SUCCESS(rv, rv); \
00128 nsCAutoString idString(id.ToString()); \
00129 NS_ENSURE_STATE(!idString.IsEmpty()); \
00130 nsXPIDLCString prevEntry; \
00131 rv = catMan->AddCategoryEntry(SB_DEVICE_MARSHALL_CATEGORY, \
00132 idString.get(), \
00133 info->mContractID, \
00134 PR_TRUE, PR_TRUE, \
00135 getter_Copies(prevEntry)); \
00136 NS_ENSURE_SUCCESS(rv, rv); \
00137 NS_WARN_IF_FALSE(prevEntry.IsEmpty(), \
00138 "Another marshall was registered with that id!"); \
00139 return NS_OK; \
00140 } \
00141 \
00142 NS_METHOD \
00143 _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
00144 nsIFile* aPath, \
00145 const char* registryLocation, \
00146 const nsModuleComponentInfo* info) \
00147 { \
00148 nsresult rv; \
00149 nsCOMPtr<nsICategoryManager> catMan = \
00150 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
00151 NS_ENSURE_SUCCESS(rv, rv); \
00152 nsID id; \
00153 rv = this->GetIdInPlace(&id); \
00154 NS_ENSURE_SUCCESS(rv, rv); \
00155 nsCAutoString idString(id.ToString()); \
00156 NS_ENSURE_STATE(!idString.IsEmpty()); \
00157 rv = catMan->DeleteCategoryEntry(SB_DEVICE_MARSHALL_CATEGORY, \
00158 idString.get(), \
00159 PR_TRUE); \
00160 NS_ENSURE_SUCCESS(rv, rv); \
00161 return NS_OK; \
00162 }
00163 %}