Added Copyright header.
[src/xds/xds-server.git] / lib / xdsserver / folder-st-disable.go
1 /*
2  * Copyright (C) 2017 "IoT.bzh"
3  * Author Sebastien Douheret <sebastien@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package xdsserver
19
20 import (
21         "github.com/iotbzh/xds-server/lib/xsapiv1"
22         uuid "github.com/satori/go.uuid"
23 )
24
25 // IFOLDER interface implementation for disabled Syncthing folders
26 // It's a "fallback" interface used to keep syncthing folders config even
27 // when syncthing is not running.
28
29 // STFolderDisable .
30 type STFolderDisable struct {
31         *Context
32         config xsapiv1.FolderConfig
33 }
34
35 // NewFolderSTDisable Create a new instance of STFolderDisable
36 func NewFolderSTDisable(ctx *Context) *STFolderDisable {
37         f := STFolderDisable{
38                 Context: ctx,
39         }
40         return &f
41 }
42
43 // NewUID Get a UUID
44 func (f *STFolderDisable) NewUID(suffix string) string {
45         uuid := uuid.NewV1().String()
46         if len(suffix) > 0 {
47                 uuid += "_" + suffix
48         }
49         return uuid
50 }
51
52 // Add a new folder
53 func (f *STFolderDisable) Add(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
54         f.config = cfg
55         f.config.Status = xsapiv1.StatusDisable
56         f.config.IsInSync = false
57         return &f.config, nil
58 }
59
60 // GetConfig Get public part of folder config
61 func (f *STFolderDisable) GetConfig() xsapiv1.FolderConfig {
62         return f.config
63 }
64
65 // GetFullPath returns the full path of a directory (from server POV)
66 func (f *STFolderDisable) GetFullPath(dir string) string {
67         return ""
68 }
69
70 // ConvPathCli2Svr Convert path from Client to Server
71 func (f *STFolderDisable) ConvPathCli2Svr(s string) string {
72         return ""
73 }
74
75 // ConvPathSvr2Cli Convert path from Server to Client
76 func (f *STFolderDisable) ConvPathSvr2Cli(s string) string {
77         return ""
78 }
79
80 // Remove a folder
81 func (f *STFolderDisable) Remove() error {
82         return nil
83 }
84
85 // Update update some fields of a folder
86 func (f *STFolderDisable) Update(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
87         return nil, nil
88 }
89
90 // RegisterEventChange requests registration for folder change event
91 func (f *STFolderDisable) RegisterEventChange(cb *FolderEventCB, data *FolderEventCBData) error {
92         return nil
93 }
94
95 // UnRegisterEventChange remove registered callback
96 func (f *STFolderDisable) UnRegisterEventChange() error {
97         return nil
98 }
99
100 // Sync Force folder files synchronization
101 func (f *STFolderDisable) Sync() error {
102         return nil
103 }
104
105 // IsInSync Check if folder files are in-sync
106 func (f *STFolderDisable) IsInSync() (bool, error) {
107         return false, nil
108 }