-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathContentUris.cpp
More file actions
57 lines (47 loc) · 1.86 KB
/
Copy pathContentUris.cpp
File metadata and controls
57 lines (47 loc) · 1.86 KB
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
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
#include "ContentUris.h"
#include "JniExceptionCheck.h"
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
ContentUris::ContentUris(QAndroidJniEnvironment& env, QObject* parent) :
QObject(parent),
m_Env(env)
{
}
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
bool ContentUris::isContentUri(const QString& uri)
{
return QUrl(uri).scheme() == "content";
}
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
bool ContentUris::parseContentUri(const QString& contentUri, QString& scheme, QString& authority, QString& treeOrDocument, QString& type, QStringList& path)
{
QRegExp rx("^(content):[/][/]([^/]*)[/](tree|document)[/](.*)%3A(.*)$");
if (rx.indexIn(contentUri) != 0)
{
return false;
}
scheme = rx.cap(1);
authority = rx.cap(2);
treeOrDocument = rx.cap(3);
type = rx.cap(4);
path = rx.cap(5).split("%2F");
return true;
}
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
QString ContentUris::buildContentUri(const QString& scheme, const QString& authority, const QString& treeOrDocument, const QString& type, const QStringList& path)
{
return scheme + "://" + authority + "/" + treeOrDocument + "/" + type + "%3A" + (path.join("%2F"));
}
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------