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 sbIMediacore;
00030 interface sbIMediacoreCapabilities;
00031
00032 [scriptable, uuid(20a5b0ee-1869-4717-bbe4-c5d9db37c6fa)]
00033 interface sbIMediacoreFactory : nsISupports
00034 {
00035 readonly attribute AString contractID;
00036 readonly attribute AString name;
00037
00038 readonly attribute sbIMediacoreCapabilities capabilities;
00039
00040 sbIMediacore create(in AString aInstanceName);
00041 };
00042
00043 %{C++
00044
00045 #include <nsIComponentManager.h>
00046 #include <nsICategoryManager.h>
00047 #include <nsIGenericFactory.h>
00048 #include <nsIServiceManager.h>
00049
00050 #include <nsCOMPtr.h>
00051 #include <nsServiceManagerUtils.h>
00052 #include <nsStringGlue.h>
00053 #include <nsXPCOMCID.h>
00054
00055 class nsIFile;
00056 struct nsModuleComponentInfo;
00057
00058 #define SB_MEDIACORE_FACTORY_CATEGORY "songbird-mediacore-factory"
00059
00081 #define SB_MEDIACORE_FACTORY_REGISTERSELF(_name) \
00082 \
00083 NS_METHOD _name##RegisterSelf(nsIComponentManager* aCompMgr, \
00084 nsIFile* aPath, \
00085 const char* registryLocation, \
00086 const char* componentType, \
00087 const nsModuleComponentInfo* info); \
00088 \
00089 NS_METHOD _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
00090 nsIFile* aPath, \
00091 const char* registryLocation, \
00092 const nsModuleComponentInfo* info)
00093
00097 #define SB_MEDIACORE_FACTORY_REGISTERSELF_IMPL(_name, _desc) \
00098 \
00099 NS_METHOD \
00100 _name##RegisterSelf(nsIComponentManager* aCompMgr, \
00101 nsIFile* aPath, \
00102 const char* registryLocation, \
00103 const char* componentType, \
00104 const nsModuleComponentInfo* info) \
00105 { \
00106 nsresult rv; \
00107 nsCOMPtr<nsICategoryManager> catMan = \
00108 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
00109 NS_ENSURE_SUCCESS(rv, rv); \
00110 nsCAutoString prevEntry; \
00111 rv = catMan->AddCategoryEntry(SB_MEDIACORE_FACTORY_CATEGORY, \
00112 _desc, \
00113 info->mContractID, \
00114 PR_TRUE, PR_TRUE, \
00115 getter_Copies(prevEntry)); \
00116 NS_ENSURE_SUCCESS(rv, rv); \
00117 NS_WARN_IF_FALSE(prevEntry.IsEmpty(), \
00118 "Another controller was registered with that id!"); \
00119 return NS_OK; \
00120 } \
00121 \
00122 NS_METHOD \
00123 _name##UnregisterSelf(nsIComponentManager* aCompMgr, \
00124 nsIFile* aPath, \
00125 const char* registryLocation, \
00126 const nsModuleComponentInfo* info) \
00127 { \
00128 nsresult rv; \
00129 nsCOMPtr<nsICategoryManager> catMan = \
00130 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); \
00131 NS_ENSURE_SUCCESS(rv, rv); \
00132 rv = catMan->DeleteCategoryEntry(SB_MEDIACORE_FACTORY_CATEGORY, \
00133 _desc, \
00134 PR_TRUE); \
00135 NS_ENSURE_SUCCESS(rv, rv); \
00136 return NS_OK; \
00137 }
00138 %}