summaryrefslogtreecommitdiff
path: root/notification-ex/shared_file.h
blob: fdd6544421c49a974b220c832c89cec9249b30f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef NOTIFICATION_EX_SHARED_FILE_H_
#define NOTIFICATION_EX_SHARED_FILE_H_

#include <security-manager.h>

#include <string>
#include <memory>
#include <list>
#include <map>
#include <vector>

#include "notification-ex/abstract_item.h"

#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
#endif

namespace notification {
namespace item {

class EXPORT_API SharedFile {
 public:
  SharedFile();
  virtual ~SharedFile();

  bool IsPrivatePath(std::string path) const;
  std::string GetDataPath(std::string app_id, std::string path) const;
  int SetPrivateSharing(std::list<std::shared_ptr<AbstractItem>> notiList,
          std::multimap<std::string, std::string> receiver_group_map);
  int UpdatePrivateSharing(std::list<std::shared_ptr<AbstractItem>> notiList,
          std::multimap<std::string, std::string> receiver_group_map);
  int RemovePrivateSharing(std::list<std::shared_ptr<AbstractItem>> notiList,
          std::multimap<std::string, std::string> receiver_group_map);
  static int CopyPrivateFile(std::shared_ptr<item::AbstractItem>added_item);

 private:
  class SharingData {
   public:
    SharingData();
    ~SharingData();
    std::string app_id;
    std::string dir;
    std::list<std::string> noti_id_list;
    std::list<std::string> shared_file_list;
    std::list<std::string> receiver_group_list;
  };
  class SharingTarget {
   public:
    SharingTarget();
    ~SharingTarget();
    std::string target_id;
  };
  static const char* GetLastIndex(const char* path, const char* search);
  static bool MakeDir(const char* path);
  static std::string GetDir(std::string path);
  static int CopyFile(const char* source, const char* dest);
  std::vector<char*> ConvertListToArray(const std::list<std::string>& data);
  SharingData FindSharingData(std::string appid);
  int SetSharingData(SharingData sharing_data,
          std::list<std::string> new_shared_file_list,
          std::list<std::string> new_receiver_group_list,
          std::multimap<std::string, std::string> receiver_group_map);
  int UnsetSharingData(SharingData sharing_data,
          std::multimap<std::string, std::string> receiver_group_map);

  std::list<SharingData> sharing_data_list_;
  std::list<SharingTarget> sharing_target_list_;
};  // class SharedFile

}  // namespace item
}  // namespace notification

#endif  // NOTIFICATION_EX_SHARED_FILE_H_