Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[commhistory-daemon] Send MMS messages with sendMessageFd. JB#50793
This allows to get around file system restrictions in case if mms-engine and commhistoryd are running under different user accounts.
- Loading branch information
Showing
4 changed files
with
128 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/****************************************************************************** | ||
** | ||
** This file is part of commhistory-daemon. | ||
** | ||
** Copyright (C) 2014-2020 Jolla Ltd. | ||
** Copyright (C) 2020 Open Mobile Platform LLC. | ||
** | ||
** This library is free software; you can redistribute it and/or modify it | ||
** under the terms of the GNU Lesser General Public License version 2.1 as | ||
** published by the Free Software Foundation. | ||
** | ||
** This library is distributed in the hope that it will be useful, but | ||
** WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | ||
** License for more details. | ||
** | ||
******************************************************************************/ | ||
|
||
#include "mmspart.h" | ||
#include <unistd.h> | ||
|
||
MmsPartFd::MmsPartFd(const QString path, const QString ct, const QString cid) : | ||
file(path), | ||
fileName(QFileInfo(path).fileName()), | ||
contentType(ct), | ||
contentId(cid) | ||
{ | ||
file.open(QIODevice::ReadOnly); | ||
} | ||
|
||
MmsPartFd::MmsPartFd(const MmsPartFd &that) : | ||
fileName(that.fileName), | ||
contentType(that.contentType), | ||
contentId(that.contentId) | ||
{ | ||
if (that.file.isOpen()) { | ||
file.open(dup(that.file.handle()), QIODevice::ReadOnly, QFileDevice::AutoCloseHandle); | ||
} | ||
} | ||
|
||
MmsPartFd &MmsPartFd::operator=(const MmsPartFd &that) | ||
{ | ||
fileName = that.fileName; | ||
contentType = that.contentType; | ||
contentId = that.contentId; | ||
file.close(); | ||
if (that.file.isOpen()) { | ||
file.open(dup(that.file.handle()), QIODevice::ReadOnly, QFileDevice::AutoCloseHandle); | ||
} | ||
return *this; | ||
} | ||
|
||
QDBusArgument &operator<<(QDBusArgument &arg, const MmsPart &part) | ||
{ | ||
arg.beginStructure(); | ||
arg << part.fileName << part.contentType << part.contentId; | ||
arg.endStructure(); | ||
return arg; | ||
} | ||
|
||
QDBusArgument &operator<<(QDBusArgument &arg, const MmsPartFd &part) | ||
{ | ||
QDBusUnixFileDescriptor fd(part.file.handle()); | ||
arg.beginStructure(); | ||
arg << fd << part.fileName << part.contentType << part.contentId; | ||
arg.endStructure(); | ||
return arg; | ||
} | ||
|
||
const QDBusArgument &operator>>(const QDBusArgument &arg, MmsPart &part) | ||
{ | ||
arg.beginStructure(); | ||
arg >> part.fileName >> part.contentType >> part.contentId; | ||
arg.endStructure(); | ||
return arg; | ||
} | ||
|
||
const QDBusArgument &operator>>(const QDBusArgument &arg, MmsPartFd &part) | ||
{ | ||
QDBusUnixFileDescriptor fd; | ||
arg.beginStructure(); | ||
arg >> fd >> part.fileName >> part.contentType >> part.contentId; | ||
arg.endStructure(); | ||
|
||
part.file.close(); | ||
if (fd.isValid()) { | ||
part.file.open(dup(fd.fileDescriptor()), QIODevice::ReadOnly, QFileDevice::AutoCloseHandle); | ||
} | ||
return arg; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters