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 nsIPropertyBag;
00030 interface nsIArray;
00031
00032 interface sbIDevice;
00033 interface sbIDeviceCompatibility;
00034
00040 [scriptable, uuid(b4b7ed5d-85f2-4d0b-a7c6-f235acad3fc0)]
00041 interface sbIDeviceController : nsISupports
00042 {
00046 readonly attribute nsIDPtr id;
00047
00051 readonly attribute AString name;
00052
00057 readonly attribute nsIDPtr marshallId;
00058
00064 readonly attribute nsIArray devices;
00065
00070 sbIDeviceCompatibility getCompatibility(in nsIPropertyBag aParams);
00071
00075 sbIDevice createDevice(in nsIPropertyBag aParams);
00076
00080 boolean controlsDevice(in sbIDevice aDevice);
00081
00085 void connectDevices();
00086
00090 void disconnectDevices();
00091
00095 void releaseDevice(in sbIDevice aDevice);
00096
00100 void releaseDevices();
00101 };
00102
00103 %{C++
00104 #include "nsCOMPtr.h"
00105 #include "nsIComponentManager.h"
00106 #include "nsICategoryManager.h"
00107 #include "nsIServiceManager.h"
00108 #include "nsStringGlue.h"
00109 #include "nsXPCOMCID.h"
00110
00111 class nsIFile;
00112 struct nsModuleComponentInfo;
00113
00114 #define SB_DEVICE_CONTROLLER_CATEGORY "songbird-device-controller"
00115
00137 #define SB_DEVICE_CONTROLLER_REGISTERSELF(_name) \
00138 \
00139 NS_METHOD _name##RegisterSelf(nsIComponentManager* aCompMgr, \
00140 nsIFile* aPath, \
00141 const char* registryLocation, \
00142 const char* componentType, \
00143 const nsModuleComponentInfo* info); \
00144 \
00145 NS_METHOD _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
00146 nsIFile* aPath, \
00147 const char* registryLocation, \
00148 const nsModuleComponentInfo* info)
00149
00153 #define SB_DEVICE_CONTROLLER_REGISTERSELF_IMPL(_name, _desc) \
00154 \
00155 NS_METHOD \
00156 _name##RegisterSelf(nsIComponentManager* aCompMgr, \
00157 nsIFile* aPath, \
00158 const char* registryLocation, \
00159 const char* componentType, \
00160 const nsModuleComponentInfo* info) \
00161 { \
00162 nsresult rv; \
00163 nsCOMPtr<nsICategoryManager> catMan = \
00164 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
00165 NS_ENSURE_SUCCESS(rv, rv); \
00166 nsCAutoString prevEntry; \
00167 rv = catMan->AddCategoryEntry(SB_DEVICE_CONTROLLER_CATEGORY, \
00168 _desc, \
00169 info->mContractID, \
00170 PR_TRUE, PR_TRUE, \
00171 getter_Copies(prevEntry)); \
00172 NS_ENSURE_SUCCESS(rv, rv); \
00173 NS_WARN_IF_FALSE(prevEntry.IsEmpty(), \
00174 "Another controller was registered with that id!"); \
00175 return NS_OK; \
00176 } \
00177 \
00178 NS_METHOD \
00179 _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
00180 nsIFile* aPath, \
00181 const char* registryLocation, \
00182 const nsModuleComponentInfo* info) \
00183 { \
00184 nsresult rv; \
00185 nsCOMPtr<nsICategoryManager> catMan = \
00186 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
00187 NS_ENSURE_SUCCESS(rv, rv); \
00188 rv = catMan->DeleteCategoryEntry(SB_DEVICE_CONTROLLER_CATEGORY, \
00189 _desc, \
00190 PR_TRUE); \
00191 NS_ENSURE_SUCCESS(rv, rv); \
00192 return NS_OK; \
00193 }
00194 %}