digiKam
dlnaserverdelegate.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2017-09-24
7  * Description : a media server to export collections through DLNA.
8  * Implementation inspired on Platinum File Media Server.
9  *
10  * Copyright (C) 2017-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_DLNA_SERVER_DELEGATE_H
25 #define DIGIKAM_DLNA_SERVER_DELEGATE_H
26 
27 // Qt includes
28 
29 #include <QString>
30 #include <QUrl>
31 #include <QList>
32 #include <QMap>
33 #include <QImage>
34 #include <QByteArray>
35 #include <QBuffer>
36 
37 // Local includes
38 
39 #include "digikam_debug.h"
40 #include "previewloadthread.h"
41 #include "dimg.h"
42 #include "drawdecoder.h"
43 
44 // Local includes
45 
46 #include "dmediaserver.h"
47 
48 // Platinum includes
49 
50 #include "Neptune.h"
51 #include "PltMediaServer.h"
52 #include "PltMediaCache.h"
53 
54 using namespace Digikam;
55 
57 {
58 
64 class DLNAMediaServerDelegate : public PLT_MediaServerDelegate
65 {
66 public:
67 
69  explicit DLNAMediaServerDelegate(const char* url_root,
70  bool use_cache = false);
71  ~DLNAMediaServerDelegate() override;
72 
74  static NPT_String BuildSafeResourceUri(const NPT_HttpUrl& base_uri,
75  const char* host,
76  const char* file_path);
77 
78  void addAlbumsOnServer(const MediaServerMap& map);
79 
80 protected:
81 
83  NPT_Result OnBrowseMetadata(PLT_ActionReference& action,
84  const char* object_id,
85  const char* filter,
86  NPT_UInt32 starting_index,
87  NPT_UInt32 requested_count,
88  const char* sort_criteria,
89  const PLT_HttpRequestContext& context) override;
90 
91  NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action,
92  const char* object_id,
93  const char* filter,
94  NPT_UInt32 starting_index,
95  NPT_UInt32 requested_count,
96  const char* sort_criteria,
97  const PLT_HttpRequestContext& context) override;
98 
99  NPT_Result OnSearchContainer(PLT_ActionReference& action,
100  const char* object_id,
101  const char* search_criteria,
102  const char* filter,
103  NPT_UInt32 starting_index,
104  NPT_UInt32 requested_count,
105  const char* sort_criteria,
106  const PLT_HttpRequestContext& context) override;
107 
108  NPT_Result ProcessFileRequest(NPT_HttpRequest& request,
109  const NPT_HttpRequestContext& context,
110  NPT_HttpResponse& response) override;
111 
113  virtual NPT_Result ExtractResourcePath(const NPT_HttpUrl& url,
114  NPT_String& file_path);
115 
116  virtual NPT_String BuildResourceUri(const NPT_HttpUrl& base_uri,
117  const char* host,
118  const char* file_path);
119 
120  virtual NPT_Result ServeFile(const NPT_HttpRequest& request,
121  const NPT_HttpRequestContext& context,
122  NPT_HttpResponse& response,
123  const NPT_String& file_path);
124 
125  virtual NPT_Result GetFilePath(const char* object_id,
126  NPT_String& filepath);
127 
128  virtual bool ProcessFile(const NPT_String&,
129  const char* filter = nullptr);
130 
131  virtual PLT_MediaObject* BuildFromFilePath(const NPT_String& filepath,
132  const PLT_HttpRequestContext& context,
133  bool with_count = true,
134  bool keep_extension_in_title = false,
135  bool allip = false);
136 
137 protected:
138 
139  friend class PLT_MediaItem;
140 
141  class Private;
142  Private* const d;
143 
144 private:
145 
146  Q_DISABLE_COPY(DLNAMediaServerDelegate)
147 };
148 
149 } // namespace DigikamGenericMediaServerPlugin
150 
151 #endif // DIGIKAM_DLNA_SERVER_DELEGATE_H
Private *const d
Definition: dlnaserverdelegate.h:141
Definition: dmediaserverdlg.cpp:54
QMap< QString, QList< QUrl > > MediaServerMap
A kind of map of albums with urls contents to share with DLNA media server.
Definition: dmediaserver.h:38
Definition: datefolderview.cpp:43