30 #include <nsAutoLock.h>
31 #include <nsComponentManagerUtils.h>
36 PLDHashOperator sbBaseDeviceController::EnumerateIntoArray(
const nsID& aKey,
40 nsIMutableArray *
array = (nsIMutableArray*)aArray;
42 nsCOMPtr<nsISupports> supports = do_QueryInterface(aData, &rv);
43 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
45 rv = array->AppendElement(aData,
false);
46 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
52 PLDHashOperator sbBaseDeviceController::EnumerateConnectAll(
const nsID& aKey,
56 nsIMutableArray *array = (nsIMutableArray*)aArray;
58 nsCOMPtr<nsISupports> supports = do_QueryInterface(aData, &rv);
59 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
61 rv = aData->Connect();
62 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
64 rv = array->AppendElement(aData,
false);
65 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
71 PLDHashOperator sbBaseDeviceController::EnumerateDisconnectAll(
const nsID& aKey,
75 nsIMutableArray *array = (nsIMutableArray*)aArray;
77 nsCOMPtr<nsISupports> supports = do_QueryInterface(aData, &rv);
78 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
80 rv = aData->Disconnect();
81 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
83 rv = array->AppendElement(aData,
false);
84 NS_ENSURE_SUCCESS(rv, PL_DHASH_STOP);
92 nsAutoMonitor::NewMonitor(
"sbBaseDeviceController.mMonitor");
93 NS_ASSERTION(mMonitor,
"Failed to create monitor");
96 NS_ASSERTION(
succeeded,
"Failed to initialize hashtable");
101 nsAutoMonitor::DestroyMonitor(mMonitor);
107 nsAutoMonitor mon(mMonitor);
113 nsAutoMonitor mon(mMonitor);
120 nsAutoMonitor mon(mMonitor);
121 aName = mControllerName;
126 nsAutoMonitor mon(mMonitor);
127 mControllerName =
aName;
133 nsAutoMonitor mon(mMonitor);
139 nsAutoMonitor mon(mMonitor);
146 NS_ENSURE_ARG_POINTER(aDevice);
150 rv = aDevice->GetId(&
id);
151 NS_ENSURE_SUCCESS(rv, rv);
152 NS_ENSURE_ARG_POINTER(
id);
154 nsAutoMonitor mon(mMonitor);
161 return succeeded ?
NS_OK : NS_ERROR_OUT_OF_MEMORY;
165 NS_ENSURE_ARG_POINTER(aDevice);
169 rv = aDevice->GetId(&
id);
170 NS_ENSURE_SUCCESS(rv, rv);
171 NS_ENSURE_ARG_POINTER(
id);
173 nsAutoMonitor mon(mMonitor);
185 NS_ENSURE_ARG_POINTER(aID);
186 NS_ENSURE_ARG_POINTER(aDevice);
188 nsAutoMonitor mon(mMonitor);
193 return succeeded ?
NS_OK : NS_ERROR_NOT_AVAILABLE;
198 NS_ENSURE_ARG_POINTER(aDevices);
201 nsCOMPtr<nsIMutableArray> array =
202 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
203 NS_ENSURE_SUCCESS(rv, rv);
205 nsAutoMonitor mon(mMonitor);
208 count =
mDevices.EnumerateRead(sbBaseDeviceController::EnumerateIntoArray,
215 rv = array->GetLength(&count);
216 NS_ENSURE_SUCCESS(rv, rv);
218 return NS_ERROR_FAILURE;
221 return CallQueryInterface(array, aDevices);
227 NS_ENSURE_ARG_POINTER(aDevice);
228 NS_ENSURE_ARG_POINTER(_retval);
231 nsresult rv = aDevice->GetId(&
id);
232 NS_ENSURE_SUCCESS(rv, rv);
234 nsCOMPtr<sbIDevice> device;
236 NS_ENSURE_SUCCESS(rv, rv);
239 *_retval = (device != nsnull) ? PR_TRUE : PR_FALSE;
246 nsAutoMonitor mon(mMonitor);
249 nsCOMPtr<nsIMutableArray> array =
250 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
251 NS_ENSURE_SUCCESS(rv, rv);
254 count =
mDevices.EnumerateRead(sbBaseDeviceController::EnumerateConnectAll,
261 rv = array->GetLength(&count);
262 NS_ENSURE_SUCCESS(rv, rv);
264 return NS_ERROR_FAILURE;
272 nsAutoMonitor mon(mMonitor);
275 nsCOMPtr<nsIMutableArray> array =
276 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
277 NS_ENSURE_SUCCESS(rv, rv);
280 count =
mDevices.EnumerateRead(sbBaseDeviceController::EnumerateDisconnectAll,
287 rv = array->GetLength(&count);
288 NS_ENSURE_SUCCESS(rv, rv);
290 return NS_ERROR_FAILURE;
298 NS_ENSURE_ARG_POINTER(aDevice);
301 nsresult rv = aDevice->GetId(&
id);
302 NS_ENSURE_SUCCESS(rv, rv);
304 aDevice->Disconnect();
306 nsAutoMonitor mon(mMonitor);
317 nsAutoMonitor mon(mMonitor);
nsresult GetDeviceInternal(const nsID *aID, sbIDevice **aDevice)
nsresult DisconnectDevicesInternal()
nsresult ReleaseDeviceInternal(sbIDevice *aDevice)
function succeeded(ch, cx, status, data)
nsresult GetMarshallIdInternal(nsID &aID)
nsresult SetMarshallIdInternal(const nsID &aID)
virtual ~sbBaseDeviceController()
nsresult SetControllerNameInternal(const nsAString &aName)
gWaitForCompletion mDevices
nsresult ReleaseDevicesInternal()
nsresult GetControllerNameInternal(nsAString &aName)
nsresult RemoveDeviceInternal(sbIDevice *aDevice)
nsresult GetDevicesInternal(nsIArray **aDevices)
nsresult AddDeviceInternal(sbIDevice *aDevice)
nsresult GetControllerIdInternal(nsID &aID)
nsresult ControlsDeviceInternal(sbIDevice *aDevice, PRBool *_retval)
nsresult SetControllerIdInternal(const nsID &aID)
nsresult ConnectDevicesInternal()
#define SB_UNUSED_IN_RELEASE(decl)
_updateTextAndScrollDataForFrame aData