BPicture: Fix archive constructor.
[haiku.git] / src / kits / package / RemoveRepositoryJob.cpp
bloba3ad23298aef22fb4613cfa500ccea5c16836224
1 /*
2 * Copyright 2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Oliver Tappe <zooey@hirschkaefer.de>
7 */
10 #include <package/RemoveRepositoryJob.h>
12 #include <Entry.h>
14 #include <package/Context.h>
15 #include <package/PackageRoster.h>
16 #include <package/RepositoryCache.h>
17 #include <package/RepositoryConfig.h>
20 namespace BPackageKit {
22 namespace BPrivate {
25 RemoveRepositoryJob::RemoveRepositoryJob(const BContext& context,
26 const BString& title, const BString& repositoryName)
28 inherited(context, title),
29 fRepositoryName(repositoryName)
34 RemoveRepositoryJob::~RemoveRepositoryJob()
39 status_t
40 RemoveRepositoryJob::Execute()
42 BPackageRoster roster;
43 BRepositoryConfig repoConfig;
44 status_t result = roster.GetRepositoryConfig(fRepositoryName, &repoConfig);
45 if (result != B_OK) {
46 if (result == B_ENTRY_NOT_FOUND) {
47 BString error = BString("repository '") << fRepositoryName
48 << "' not found!";
49 SetErrorString(error);
51 return result;
54 BString question = BString("Really remove the repository '")
55 << fRepositoryName << "'?";
56 bool yes = fContext.DecisionProvider().YesNoDecisionNeeded("", question,
57 "yes", "no", "no");
58 if (!yes)
59 return B_CANCELED;
61 BEntry repoConfigEntry = repoConfig.Entry();
62 if ((result = repoConfigEntry.Remove()) != B_OK)
63 return result;
65 BRepositoryCache repoCache;
66 if (roster.GetRepositoryCache(fRepositoryName, &repoCache) == B_OK) {
67 BEntry repoCacheEntry = repoCache.Entry();
68 if ((result = repoCacheEntry.Remove()) != B_OK)
69 return result;
72 return B_OK;
76 } // namespace BPrivate
78 } // namespace BPackageKit