File indexing completed on 2024-05-19 05:50:39
0001 /************************************************************************************* 0002 * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #include "sambahelper.h" 0020 0021 #include <locale.h> 0022 #include <unistd.h> 0023 #include <QProcess> 0024 0025 ActionReply SambaHelper::mount(QVariantMap args) 0026 { 0027 QString ip = args["ip"].toString(); 0028 QString uid = args["uid"].toString(); 0029 QString sambaDir = args["sambaDir"].toByteArray(); 0030 QString mountPoint = args["mountPoint"].toByteArray(); 0031 QString locale = args["locale"].toString(); 0032 QString path = args["path"].toString(); 0033 QString username = args["username"].toString(); 0034 QString password = args["password"].toString(); 0035 0036 setenv("LANG", locale.toLocal8Bit(), 1); 0037 setenv("PATH", path.toLocal8Bit(), 1); 0038 setlocale(LC_CTYPE, locale.toLocal8Bit()); 0039 0040 QProcess proc; 0041 proc.start("samba-realmounter", {ip, sambaDir, mountPoint, uid, username, password }); 0042 proc.waitForFinished(); 0043 0044 ActionReply reply; 0045 reply.addData("output", proc.readAllStandardOutput()); 0046 reply.addData("error", proc.readAllStandardError()); 0047 reply.addData("exitCode", proc.exitCode()); 0048 0049 return reply; 0050 } 0051 0052 ActionReply SambaHelper::umount(QVariantMap args) 0053 { 0054 QString locale = args["locale"].toString(); 0055 QString path = args["path"].toString(); 0056 setenv("LANG", locale.toLocal8Bit(), 1); 0057 setenv("PATH", path.toLocal8Bit(), 1); 0058 setlocale(LC_CTYPE, locale.toLocal8Bit()); 0059 0060 QProcess proc; 0061 proc.start("samba-realumounter", {args["mountPoint"].toString()}); 0062 proc.waitForFinished(); 0063 0064 return ActionReply::SuccessReply(); 0065 } 0066 0067 KAUTH_HELPER_MAIN("org.kde.sambamounter", SambaHelper) 0068 // int main(int argc, char **argv) { setlocale(LC_CTYPE, "en_US.UTF-8"); return KAuth::HelperSupport::helperMain(argc, argv, "org.kde.sambamounter", new SambaHelper ()); }