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
12using namespace BNetworkKit;
13
14
15BNetworkProfile::BNetworkProfile()
16	:
17	fIsDefault(false),
18	fIsCurrent(false),
19	fName(NULL)
20{
21}
22
23
24BNetworkProfile::BNetworkProfile(const char* path)
25	:
26	fIsDefault(false),
27	fIsCurrent(false)
28{
29	SetTo(path);
30}
31
32
33BNetworkProfile::BNetworkProfile(const entry_ref& ref)
34	:
35	fIsDefault(false),
36	fIsCurrent(false)
37{
38	SetTo(ref);
39}
40
41
42BNetworkProfile::BNetworkProfile(const BEntry& entry)
43	:
44	fIsDefault(false),
45	fIsCurrent(false)
46{
47	SetTo(entry);
48}
49
50
51BNetworkProfile::~BNetworkProfile()
52{
53}
54
55
56status_t
57BNetworkProfile::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
69status_t
70BNetworkProfile::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
82status_t
83BNetworkProfile::SetTo(const BEntry& entry)
84{
85	fEntry = entry;
86	fPath.Unset();
87	fName = NULL;
88	return B_OK;
89}
90
91
92const char*
93BNetworkProfile::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
104status_t
105BNetworkProfile::SetName(const char* name)
106{
107	return B_OK;
108}
109
110
111bool
112BNetworkProfile::Exists()
113{
114	return fEntry.Exists();
115}
116
117
118status_t
119BNetworkProfile::Delete()
120{
121	return B_ERROR;
122}
123
124
125bool
126BNetworkProfile::IsDefault()
127{
128	return fIsDefault;
129}
130
131
132bool
133BNetworkProfile::IsCurrent()
134{
135	return fIsCurrent;
136}
137
138
139status_t
140BNetworkProfile::MakeCurrent()
141{
142	return B_ERROR;
143}
144
145
146// #pragma mark -
147
148
149BNetworkProfile*
150BNetworkProfile::Default()
151{
152	return NULL;
153}
154
155
156BNetworkProfile*
157BNetworkProfile::Current()
158{
159	return NULL;
160}
161