29 #include <sbIDeviceLibrary.h>
31 #include <nsArrayEnumerator.h>
32 #include <nsComponentManagerUtils.h>
33 #include <nsISimpleEnumerator.h>
34 #include <nsServiceManagerUtils.h>
43 static PRLogModuleInfo* gDeviceContentLog = nsnull;
44 #define TRACE(args) PR_LOG(gDeviceContentLog, PR_LOG_DEBUG, args)
45 #define LOG(args) PR_LOG(gDeviceContentLog, PR_LOG_WARN, args)
51 sbDeviceContent::sbDeviceContent()
52 : mDeviceLibrariesMonitor(nsnull)
55 if (!gDeviceContentLog) {
56 gDeviceContentLog = PR_NewLogModule(
"sbDeviceContent");
59 TRACE((
"DeviceContent[0x%.8x] - Constructed",
this));
62 sbDeviceContent::~sbDeviceContent()
66 if(mDeviceLibrariesMonitor) {
67 nsAutoMonitor::DestroyMonitor(mDeviceLibrariesMonitor);
69 TRACE((
"DeviceContent[0x%.8x] - Destructed",
this));
78 sbDeviceContent::Initialize()
80 mDeviceLibrariesMonitor = nsAutoMonitor::NewMonitor(
"sbDeviceContent::mDeviceLibrariesMonitor");
81 NS_ENSURE_TRUE(mDeviceLibrariesMonitor, NS_ERROR_OUT_OF_MEMORY);
85 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
86 NS_ENSURE_SUCCESS(rv, rv);
92 sbDeviceContent::Finalize()
97 if (mDeviceLibraries) {
99 rv = mDeviceLibraries->GetLength(&length);
100 if (NS_SUCCEEDED(rv)) {
101 for (PRUint32
i = 0;
i < length;
i++) {
102 nsCOMPtr<sbIDeviceLibrary> library;
103 rv = mDeviceLibraries->QueryElementAt(
i,
105 getter_AddRefs(library));
106 if (NS_SUCCEEDED(rv))
110 mDeviceLibraries->Clear();
117 sbDeviceContent::GetLibraries(nsIArray** aLibraries)
119 NS_ENSURE_ARG_POINTER(aLibraries);
121 nsAutoMonitor mon(mDeviceLibrariesMonitor);
122 *aLibraries = mDeviceLibraries;
123 NS_ADDREF(*aLibraries);
130 return NS_ERROR_NOT_IMPLEMENTED;
136 NS_ENSURE_ARG_POINTER(aLibrary);
139 nsAutoMonitor mon(mDeviceLibrariesMonitor);
140 PRUint32 existingIndex;
141 rv = FindLibrary(aLibrary, &existingIndex);
143 rv = mDeviceLibraries->AppendElement(aLibrary,
false);
144 NS_ENSURE_SUCCESS(rv, rv);
153 NS_ENSURE_ARG_POINTER(aLibrary);
157 rv = FindLibrary(aLibrary, &itemIndex);
162 nsAutoMonitor mon(mDeviceLibrariesMonitor);
163 rv = mDeviceLibraries->RemoveElementAt(itemIndex);
164 NS_ENSURE_SUCCESS(rv, rv);
172 NS_ENSURE_ARG_POINTER(aLibrary);
173 NS_ENSURE_ARG_POINTER(_retval);
175 nsAutoMonitor mon(mDeviceLibrariesMonitor);
178 rv = mDeviceLibraries->IndexOf(0, aLibrary, &index);
179 if (rv == NS_ERROR_FAILURE) {
181 return NS_ERROR_NOT_AVAILABLE;
183 NS_ENSURE_SUCCESS(rv, rv);
185 *_retval = (PRUint32)index;
Factory for new library instances.
[UNIMPLEMENTED UNTIL AFTER 0.3]
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceCapsCompatibility, sbIDeviceCapsCompatibility) sbDeviceCapsCompatibility
NS_DECL_ISUPPORTS static NS_DECL_SBIDEVICECONTENT sbDeviceContent * New()
_getSelectedPageStyle s i