sbLinuxFileSystemWatcher.h
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2009 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #ifndef sbLinuxFileSystemWatcher_h_
28 #define sbLinuxFileSystemWatcher_h_
29 
31 #include <sbIFileSystemWatcher.h>
32 #include <sbFileSystemTree.h>
33 #include <nsStringAPI.h>
34 #include <nsCOMPtr.h>
35 #include <map>
36 #include <glib.h>
37 
38 typedef std::map<int, nsString> sbFileDescMap;
39 
40 
42 {
43 public:
45  virtual ~sbLinuxFileSystemWatcher();
46 
47  NS_IMETHOD StopWatching(PRBool aShouldSaveSession);
48 
49  nsresult OnInotifyEvent();
50 
51  // |sbFileSystemTreeListener|
52  NS_IMETHOD OnChangeFound(const nsAString & aChangePath,
53  EChangeType aChangeType);
54  NS_IMETHOD OnTreeReady(const nsAString & aTreeRootPath,
55  sbStringArray & aDirPathArray);
56 
57 protected:
58  //
59  // \brief Close and cleanup all the inotify and file-system data structures.
60  //
61  nsresult Cleanup();
62 
63  //
64  // \brief Add a inotify resource to watch. This function will also add the
65  // necessary entry to the file descriptor map.
66  // \param aDirPath The absolute path of the directory to watch.
67  //
68  nsresult AddInotifyHook(const nsAString & aDirPath);
69 
70 private:
71  int mInotifyFileDesc;
72  guint mInotifySource; // inotify gsource descriptor
73  sbFileDescMap mFileDescMap;
74 };
75 
76 #endif // sbLinuxFileSystemWatcher_h_
77 
nsresult AddInotifyHook(const nsAString &aDirPath)
nsTArray< nsString > sbStringArray
std::map< int, nsString > sbFileDescMap
NS_IMETHOD OnTreeReady(const nsAString &aTreeRootPath, sbStringArray &aDirPathArray)
NS_IMETHOD OnChangeFound(const nsAString &aChangePath, EChangeType aChangeType)
NS_IMETHOD StopWatching(PRBool aShouldSaveSession)