2 * Copyright 2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Oliver Tappe <zooey@hirschkaefer.de>
10 #include <package/RemoveRepositoryJob.h>
14 #include <package/Context.h>
15 #include <package/PackageRoster.h>
16 #include <package/RepositoryCache.h>
17 #include <package/RepositoryConfig.h>
20 namespace BPackageKit
{
25 RemoveRepositoryJob::RemoveRepositoryJob(const BContext
& context
,
26 const BString
& title
, const BString
& repositoryName
)
28 inherited(context
, title
),
29 fRepositoryName(repositoryName
)
34 RemoveRepositoryJob::~RemoveRepositoryJob()
40 RemoveRepositoryJob::Execute()
42 BPackageRoster roster
;
43 BRepositoryConfig repoConfig
;
44 status_t result
= roster
.GetRepositoryConfig(fRepositoryName
, &repoConfig
);
46 if (result
== B_ENTRY_NOT_FOUND
) {
47 BString error
= BString("repository '") << fRepositoryName
49 SetErrorString(error
);
54 BString question
= BString("Really remove the repository '")
55 << fRepositoryName
<< "'?";
56 bool yes
= fContext
.DecisionProvider().YesNoDecisionNeeded("", question
,
61 BEntry repoConfigEntry
= repoConfig
.Entry();
62 if ((result
= repoConfigEntry
.Remove()) != B_OK
)
65 BRepositoryCache repoCache
;
66 if (roster
.GetRepositoryCache(fRepositoryName
, &repoCache
) == B_OK
) {
67 BEntry repoCacheEntry
= repoCache
.Entry();
68 if ((result
= repoCacheEntry
.Remove()) != B_OK
)
76 } // namespace BPrivate
78 } // namespace BPackageKit