From owner-p4-projects@FreeBSD.ORG Fri Jun 12 17:16:01 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 32B421065675; Fri, 12 Jun 2009 17:16:01 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E593D1065673 for ; Fri, 12 Jun 2009 17:16:00 +0000 (UTC) (envelope-from jona@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D406F8FC12 for ; Fri, 12 Jun 2009 17:16:00 +0000 (UTC) (envelope-from jona@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5CHG0dQ005976 for ; Fri, 12 Jun 2009 17:16:00 GMT (envelope-from jona@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5CHG0ps005974 for perforce@freebsd.org; Fri, 12 Jun 2009 17:16:00 GMT (envelope-from jona@FreeBSD.org) Date: Fri, 12 Jun 2009 17:16:00 GMT Message-Id: <200906121716.n5CHG0ps005974@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jona@FreeBSD.org using -f From: Jonathan Anderson To: Perforce Change Reviews Cc: Subject: PERFORCE change 164187 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jun 2009 17:16:02 -0000 http://perforce.freebsd.org/chv.cgi?CH=164187 Change 164187 by jona@jona-trustedbsd-kent on 2009/06/12 17:15:39 KDE powerboxes - 'test' requests powerboxes from kpowerboxserver using D-Bus IPC Affected files ... .. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/CMakeLists.txt#3 edit .. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/cleanup.sh#1 add .. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.cpp#2 edit .. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.h#2 edit .. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/powerbox.h#2 edit .. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/test.cpp#1 add Differences ... ==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/CMakeLists.txt#3 (text+ko) ==== @@ -1,16 +1,23 @@ cmake_minimum_required(VERSION 2.6) -project(kpowerboxtest) +project(kpowerboxserver) find_package(KDE4 REQUIRED) find_package(Qt4 REQUIRED) include(${QT_USE_FILE}) -set(test_SRC kpowerboxtest.cpp kpowerboxserver.cpp) +set(server_SRC main.cpp kpowerboxserver.cpp) +set(server_MOC_HDRS kpowerboxserver.h) +#qt4_wrap_cpp(server_MOC_SRC ${server_MOC_HDRS}) +#KDE4_AUTOMOC(${server_SRC}) + + +set(test_SRC test.cpp) -qt4_automoc(${source}) +kde4_add_executable(test ${test_SRC}) +target_link_libraries(test ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS}) -kde4_add_executable(kpowerboxtest ${test_SRC}) -target_link_libraries(kpowerboxtest ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS}) +kde4_add_executable(kpowerboxserver ${server_SRC})# ${server_MOC_SRC}) +target_link_libraries(kpowerboxserver ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS}) ==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.cpp#2 (text+ko) ==== @@ -4,12 +4,8 @@ #include -#include -#include - #include "powerbox.h" -#include "kpowerboxserver.moc" - +#include "kpowerboxserver.h" KPowerBoxServer::KPowerBoxServer() @@ -18,19 +14,11 @@ } -QMap KPowerBoxServer::showKDEPowerbox(struct capbox_options *options) +QStringList +KPowerBoxServer::showKDEPowerbox(int operation, QString title, QString parent, + QString startDir, QString filter, bool allowMultipleSelections) { - QMap fileDescriptors; - - if(options->ui != CAPBOX_KDE) - { - fileDescriptors[-1] = - "Error: this is a KDE powerbox; we can only handle UI type CAPBOX_KDE"; - - return fileDescriptors; - } - - if(options->mult) + if(allowMultipleSelections) { // TODO: get KDE to support WId for multi-select dialogs std::cerr @@ -38,56 +26,45 @@ << " dialogs, so we can't support multiple selection (for now)" << std::endl; - options->mult = false; + allowMultipleSelections = false; } - QString startDir = options->start_path; - QString filter = options->filter; - WId parent = options->parent_window; - QString title = options->window_title; + int base = 10; + if(parent.startsWith("0x")) + { + parent.replace("0x", ""); + base = 16; + } + WId parentWId = parent.toLong(NULL, base); QStringList filenames; - switch(options->operation) + switch(operation) { case OPEN_FILE: - if(options->mult) + if(allowMultipleSelections) + // TODO: multiple selection via WId filenames = KFileDialog::getOpenFileNames(startDir, filter, NULL, title); else filenames << - KFileDialog::getOpenFileNameWId(startDir, filter, parent, title); + KFileDialog::getOpenFileNameWId(startDir, filter, parentWId, title); break; case SAVE_FILE: filenames << - KFileDialog::getSaveFileNameWId(startDir, filter, parent, title); + KFileDialog::getSaveFileNameWId(startDir, filter, parentWId, title); break; case SELECT_DIR: + // TODO: directory selection via WId filenames << KFileDialog::getExistingDirectory(startDir, NULL, title); break; } - - for(int i = 0; i < filenames.size(); i++) - { - QString filename = filenames.at(i); - - int flags = 0; - if((options->rights & 6) == 6) flags |= O_RDWR; - else if((options->rights & 6) == 4) flags |= O_RDONLY; - else if((options->rights & 6) == 2) flags |= O_WRONLY; - -// if(options->rights & 1) flags |= O_EXEC; TODO: no O_EXEC under Linux? - - int fd = open(filename.toStdString().c_str(), flags); - fileDescriptors[fd] = filename; - } - - return fileDescriptors; + return filenames; } ==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.h#2 (text+ko) ==== @@ -1,7 +1,13 @@ -#include + +#ifndef KPOWERBOX_SERVER +#define KPOWERBOX_SERVER + +#include #include #include +#include + #include "powerbox.h" @@ -12,6 +18,7 @@ { Q_OBJECT + public: KPowerBoxServer(); @@ -20,8 +27,26 @@ /** * Shows a KDE-based PowerBox. * - * @return a map of file descriptors and their associated file names + * This is a very long list of parameters, but we have to use Qt-friendly types + * in order for Qt to do the D-Bus marshalling and unmarshalling for us. + * + * @param operation what we're doing (see powerbox.h) + * @param title the title of the dialog box + * @param parent ID of the parent window (to pop up in front of) + * @param startDir where to look for files + * @param filter selection filter (e.g. "*.cpp") + * @param allowMultipleSelections allow multiple selection + * + * @return a list of file names */ - QMap showKDEPowerbox(struct capbox_options *options); + Q_SCRIPTABLE QStringList showKDEPowerbox( + int operation, + QString title, + QString parent, + QString startDir, + QString filter, + bool allowMultipleSelections = false); }; +#endif + ==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/powerbox.h#2 (text+ko) ====