1 /* 2 * Copyright 2004-2015 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <NetworkProfile.h> 8 9 #include <stdlib.h> 10 11 12 using namespace BNetworkKit; 13 14 15 BNetworkProfile::BNetworkProfile() 16 : 17 fIsDefault(false), 18 fIsCurrent(false), 19 fName(NULL) 20 { 21 } 22 23 24 BNetworkProfile::BNetworkProfile(const char* path) 25 : 26 fIsDefault(false), 27 fIsCurrent(false) 28 { 29 SetTo(path); 30 } 31 32 33 BNetworkProfile::BNetworkProfile(const entry_ref& ref) 34 : 35 fIsDefault(false), 36 fIsCurrent(false) 37 { 38 SetTo(ref); 39 } 40 41 42 BNetworkProfile::BNetworkProfile(const BEntry& entry) 43 : 44 fIsDefault(false), 45 fIsCurrent(false) 46 { 47 SetTo(entry); 48 } 49 50 51 BNetworkProfile::~BNetworkProfile() 52 { 53 } 54 55 56 status_t 57 BNetworkProfile::SetTo(const char* path) 58 { 59 status_t status = fEntry.SetTo(path, true); 60 if (status != B_OK) 61 return status; 62 63 fPath.Unset(); 64 fName = NULL; 65 return B_OK; 66 } 67 68 69 status_t 70 BNetworkProfile::SetTo(const entry_ref& ref) 71 { 72 status_t status = fEntry.SetTo(&ref); 73 if (status != B_OK) 74 return status; 75 76 fPath.Unset(); 77 fName = ref.name; 78 return B_OK; 79 } 80 81 82 status_t 83 BNetworkProfile::SetTo(const BEntry& entry) 84 { 85 fEntry = entry; 86 fPath.Unset(); 87 fName = NULL; 88 return B_OK; 89 } 90 91 92 const char* 93 BNetworkProfile::Name() 94 { 95 if (fName == NULL) { 96 if (fEntry.GetPath(&fPath) == B_OK) 97 fName = fPath.Leaf(); 98 } 99 100 return fName; 101 } 102 103 104 status_t 105 BNetworkProfile::SetName(const char* name) 106 { 107 return B_OK; 108 } 109 110 111 bool 112 BNetworkProfile::Exists() 113 { 114 return fEntry.Exists(); 115 } 116 117 118 status_t 119 BNetworkProfile::Delete() 120 { 121 return B_ERROR; 122 } 123 124 125 bool 126 BNetworkProfile::IsDefault() 127 { 128 return fIsDefault; 129 } 130 131 132 bool 133 BNetworkProfile::IsCurrent() 134 { 135 return fIsCurrent; 136 } 137 138 139 status_t 140 BNetworkProfile::MakeCurrent() 141 { 142 return B_ERROR; 143 } 144 145 146 // #pragma mark - 147 148 149 BNetworkProfile* 150 BNetworkProfile::Default() 151 { 152 return NULL; 153 } 154 155 156 BNetworkProfile* 157 BNetworkProfile::Current() 158 { 159 return NULL; 160 } 161