sbBaseDeviceMarshall.h
Go to the documentation of this file.
1 #ifndef SBBASEDEVICEMARSHALL_H_
2 #define SBBASEDEVICEMARSHALL_H_
3 
4 /*
5  //
6  // BEGIN SONGBIRD GPL
7  //
8  // This file is part of the Songbird web player.
9  //
10  // Copyright(c) 2005-2008 POTI, Inc.
11  // http://songbirdnest.com
12  //
13  // This file may be licensed under the terms of of the
14  // GNU General Public License Version 2 (the "GPL").
15  //
16  // Software distributed under the License is distributed
17  // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
18  // express or implied. See the GPL for the specific language
19  // governing rights and limitations.
20  //
21  // You should have received a copy of the GPL along with this
22  // program. If not, go to http://www.gnu.org/licenses/gpl.html
23  // or write to the Free Software Foundation, Inc.,
24  // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  //
26  // END SONGBIRD GPL
27  //
28  */
29 
30 #include <sbIDeviceMarshall.h>
31 #include <nsCOMPtr.h>
32 #include <sbIDeviceCompatibility.h>
33 #include <nsID.h>
34 #include <nsIArray.h>
35 
38 class nsIPropertyBag;
40 
53 {
54 public:
59  {
60  public:
65  mBestMatch(nsnull)
66  {
67  }
72  virtual PRBool Compare(sbIDeviceController* controller,
73  nsIPropertyBag* deviceParams);
78  {
79  return mBestMatch;
80  }
81  protected:
85  void SetBestMatch(sbIDeviceController* deviceController, sbIDeviceCompatibility * compatibility)
86  {
87  mBestMatch = deviceController;
88  mCompatibility = compatibility;
89  }
90  private:
94  sbIDeviceController* mBestMatch;
95  nsCOMPtr<sbIDeviceCompatibility> mCompatibility;
96  };
100  sbIDeviceController* FindCompatibleControllers(nsIPropertyBag* deviceParams)
101  {
102  CompatibilityComparer comparer;
103  return FindCompatibleControllers(deviceParams, comparer);
104  }
108  sbIDeviceController* FindCompatibleControllers(nsIPropertyBag* deviceParams,
109  CompatibilityComparer & deviceComparer);
110 protected:
114  virtual ~sbBaseDeviceMarshall();
118  sbBaseDeviceMarshall(nsACString const & categoryName);
124  nsIArray* GetControllers() const
125  {
126  if (!mControllers) {
127  // Logically const
128  if (!const_cast<sbBaseDeviceMarshall*>(this)->RefreshControllers()) {
129  NS_ASSERTION(PR_FALSE, "Something bad happened while refreshing the controllers");
130  return nsnull;
131  }
132  }
133  return mControllers.get();
134  }
138  nsIArray* RefreshControllers();
145  {
146  mIsMonitoring = PR_FALSE;
147  }
151  PRBool IsMonitoring() const
152  {
153  return mIsMonitoring;
154  }
155 private:
156  nsCOMPtr<nsIArray> mControllers;
157  nsCString mCategoryName;
158  PRBool mIsMonitoring;
162  nsresult GetCategoryManagerEnumerator(nsCOMPtr<nsISimpleEnumerator> & enumerator);
163 };
164 
165 #endif
var registrar
nsIArray * GetControllers() const
virtual PRBool Compare(sbIDeviceController *controller, nsIPropertyBag *deviceParams)
sbBaseDeviceMarshall(nsACString const &categoryName)
PRBool IsMonitoring() const
sbIDeviceController * FindCompatibleControllers(nsIPropertyBag *deviceParams)
[UNIMPLEMENTED UNTIL AFTER 0.3]
void RegisterControllers(sbIDeviceControllerRegistrar *registrar)
[UNIMPLEMENTED UNTIL AFTER 0.3]
[UNIMPLEMENTED UNTIL AFTER 0.3]
sbIDeviceController * GetBestMatch() const
void SetBestMatch(sbIDeviceController *deviceController, sbIDeviceCompatibility *compatibility)