sbWatchFolderUtils.cpp
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2009 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 #include "sbWatchFolderUtils.h"
26 
27 #include <sbIWatchFolderService.h>
28 
29 #include <nsComponentManagerUtils.h>
30 #include <nsServiceManagerUtils.h>
31 
32 #include <sbDebugUtils.h>
33 
34 //==============================================================================
35 // sbAutoIgnoreWatchFolderPath implementation
36 //==============================================================================
37 
39 
41  : mWFService(nsnull)
42  , mIsIgnoring(PR_FALSE)
43 {
44 }
45 
47 {
48  // If the path was watched, it is now time to clean up and stop ignoring
49  // the watch path.
50  if (mIsIgnoring) {
51  nsresult SB_UNUSED_IN_RELEASE(rv) = mWFService->RemoveIgnorePath(mWatchPath);
52  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
53  "Could not remove a file path from the watchfolders ignore list!");
54  }
55 }
56 
57 nsresult
58 sbAutoIgnoreWatchFolderPath::Init(nsAString const & aWatchPath)
59 {
60  mWatchPath = aWatchPath;
61 
62  nsresult rv;
63  mWFService = do_GetService("@songbirdnest.com/watch-folder-service;1", &rv);
64  NS_ENSURE_SUCCESS(rv, rv);
65 
66  PRBool isRunning = PR_FALSE;
67  rv = mWFService->GetIsRunning(&isRunning);
68  NS_ENSURE_SUCCESS(rv, rv);
69 
70  // If the watchfolder service is not running, don't bother appending to the
71  // ignore path list.
72  if (!isRunning) {
73  return NS_OK;
74  }
75 
76  rv = mWFService->AddIgnorePath(mWatchPath);
77  NS_ENSURE_SUCCESS(rv, rv);
78 
79  mIsIgnoring = PR_TRUE;
80  return NS_OK;
81 }
NS_IMPL_THREADSAFE_ISUPPORTS0(sbMetadataCrashTracker)
return NS_OK
NS_DECL_ISUPPORTS nsresult Init(nsAString const &aWatchPath)
#define SB_UNUSED_IN_RELEASE(decl)
Definition: sbDebugUtils.h:55