1 /* 2 * Copyright 2013-2021, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold <ingo_weinhold@gmx.de> 7 * Stephan Aßmus <superstippi@gmx.de> 8 * Rene Gollent <rene@gollent.com> 9 * Julian Harnath <julian.harnath@rwth-aachen.de> 10 * Andrew Lindesay <apl@lindesay.co.nz> 11 * 12 * Note that this file has been re-factored from `PackageManager.cpp` and 13 * authors have been carried across in 2021. 14 */ 15 16 17 #include "DeskbarLink.h" 18 19 #include "Logger.h" 20 21 22 #define kPathKey "path" 23 #define kLinkKey "link" 24 25 26 DeskbarLink::DeskbarLink() 27 { 28 } 29 30 31 DeskbarLink::DeskbarLink(const BString& path, const BString& link) 32 : 33 fPath(path), 34 fLink(link) 35 { 36 } 37 38 39 DeskbarLink::DeskbarLink(const DeskbarLink& other) 40 : 41 fPath(other.fPath), 42 fLink(other.fLink) 43 { 44 } 45 46 47 DeskbarLink::DeskbarLink(BMessage* from) 48 { 49 if (from->FindString(kPathKey, &fPath) != B_OK) { 50 HDERROR("expected key [%s] in the message data when creating a " 51 "captcha", kPathKey); 52 } 53 54 if (from->FindString(kLinkKey, &fLink) != B_OK) { 55 HDERROR("expected key [%s] in the message data when creating a " 56 "captcha", kLinkKey); 57 } 58 } 59 60 61 62 DeskbarLink::~DeskbarLink() 63 { 64 } 65 66 67 const BString 68 DeskbarLink::Path() const 69 { 70 return fPath; 71 } 72 73 74 const BString 75 DeskbarLink::Link() const 76 { 77 return fLink; 78 } 79 80 81 status_t 82 DeskbarLink::Archive(BMessage* into, bool deep) const 83 { 84 status_t result = B_OK; 85 if (result == B_OK && into == NULL) 86 result = B_ERROR; 87 if (result == B_OK) 88 result = into->AddString(kPathKey, fPath); 89 if (result == B_OK) 90 result = into->AddString(kLinkKey, fLink); 91 return result; 92 } 93 94 95 DeskbarLink& 96 DeskbarLink::operator=(const DeskbarLink& other) 97 { 98 if (this == &other) 99 return *this; 100 fPath = other.Path(); 101 fLink = other.Link(); 102 return *this; 103 } 104 105 106 bool 107 DeskbarLink::operator==(const DeskbarLink& other) 108 { 109 return fPath == other.fPath && fLink == other.fLink; 110 } 111 112 113 bool 114 DeskbarLink::operator!=(const DeskbarLink& other) 115 { 116 return !(*this == other); 117 } 118