int mountDriveUDisks2(TQString deviceNode, TQString fileSystemType, TQString mountOptions, TQString* errStr = NULL) { #ifdef WITH_UDISKS2 TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); if (dbusConn.isConnected()) { TQString blockDeviceString = deviceNode; blockDeviceString.replace("/dev/", ""); blockDeviceString = "/org/freedesktop/UDisks2/block_devices/" + blockDeviceString; // Mount the drive! TQT_DBusError error; TQT_DBusProxy driveControl("org.freedesktop.UDisks2", blockDeviceString, "org.freedesktop.UDisks2.Filesystem", dbusConn); if (driveControl.canSend()) { TQValueList<TQT_DBusData> params; TQMap<TQString, TQT_DBusData> optionsMap; if (fileSystemType != "") { optionsMap["fstype"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(fileSystemType)); } optionsMap["options"] = convertDBUSDataToVariantData(TQT_DBusData::fromString(mountOptions)); params << TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(optionsMap)); TQT_DBusMessage reply = driveControl.sendWithReply("Mount", params, &error); if (error.isValid()) { // Error! if (error.name() == "org.freedesktop.DBus.Error.ServiceUnknown") { // Service not installed or unavailable return -2; } if (errStr) { *errStr = error.name() + ": " + error.message(); } else { printf("[ERROR][tdehwlib] mountDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); } return -1; } else { return 0; } } else { return -2; } } #endif // WITH_UDISKS2 return -2; }
int mountDriveUDisks(TQString deviceNode, TQString fileSystemType, TQStringList mountOptions, TQString* errStr = NULL) { #ifdef WITH_UDISKS TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); if (dbusConn.isConnected()) { TQString blockDeviceString = deviceNode; blockDeviceString.replace("/dev/", ""); blockDeviceString = "/org/freedesktop/UDisks/devices/" + blockDeviceString; // Mount the drive! TQT_DBusError error; TQT_DBusProxy driveControl("org.freedesktop.UDisks", blockDeviceString, "org.freedesktop.UDisks.Device", dbusConn); if (driveControl.canSend()) { TQValueList<TQT_DBusData> params; params << TQT_DBusData::fromString(fileSystemType); params << TQT_DBusData::fromList(TQT_DBusDataList(mountOptions)); TQT_DBusMessage reply = driveControl.sendWithReply("FilesystemMount", params, &error); if (error.isValid()) { // Error! if (error.name() == "org.freedesktop.DBus.Error.ServiceUnknown") { // Service not installed or unavailable return -2; } if (errStr) { *errStr = error.name() + ": " + error.message(); } else { printf("[ERROR][tdehwlib] mountDriveUDisks: %s\n", error.name().ascii()); fflush(stdout); } return -1; } else { return 0; } } else { return -2; } } #endif // WITH_UDISKS return -2; }
task main() { initializeRobot(); waitForStart(); // wait for start of tele-op phase arm_fsm = 1; //arm_fsm = 0; while (true) { getJoystickSettings(joystick); //Required for driver control if(joy1Btn(9) && joy1Btn(10)) { arm_fsm = 2; } driveControl(); armControl(); manipulatorControl(); flagControl(); } }
// Call once per frame. // void driveUpdate(void) { DROID *psDroid; PROPULSION_STATS *psPropStats; AllInRange = true; if(DirectControl) { if(psDrivenDroid != NULL) { if(bMultiMessages && (driveBumpTime < gameTime)) // send latest info about driven droid. { sendDroidInfo(psDrivenDroid, DORDER_MOVE, psDrivenDroid->pos.x, psDrivenDroid->pos.y, NULL, NULL, 0, 0, 0, false); } //TO BE DONE: //clear the order on taking over the droid, to stop attacks.. //send some sort of message when droids stopo and get inrange. // Check the driven droid is still selected if(psDrivenDroid->selected == false) { // if it's not then reset the driving system. driveSelectionChanged(); return; } // Update the driven droid. if(driveControl(psDrivenDroid)) { // If control did something then force the droid's move status. if(psDrivenDroid->sMove.Status != MOVEDRIVE) { psDrivenDroid->sMove.Status = MOVEDRIVE; ASSERT( (psDrivenDroid->droidType != DROID_TRANSPORTER),"Tried to control a transporter" ); driveDir = UNDEG(psDrivenDroid->rot.direction); } DoFollowRangeCheck = true; } // Is the driven droid under user control? if(psDrivenDroid->sMove.Status == MOVEDRIVE) { // Is it a command droid if( (psDrivenDroid->droidType == DROID_COMMAND) && (psDrivenDroid->psGroup != NULL) ) { driveMoveCommandFollowers(psDrivenDroid); } for(psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat; if( (psDroid->selected) && (psDroid != psDrivenDroid) && (psDroid->droidType != DROID_TRANSPORTER) && //((psPropStats->propulsionType != PROPULSION_TYPE_LIFT) || (psDroid->droidType == DROID_CYBORG)) ) { ((psPropStats->propulsionType != PROPULSION_TYPE_LIFT) || cyborgDroid(psDroid)) ) { // Send new orders to it's followers. driveMoveFollower(psDroid); } } } if(AllInRange) { DoFollowRangeCheck = false; } if(driveBumpTime < gameTime) { // Send next order in 1 second. driveBumpTime = gameTime+GAME_TICKS_PER_SEC; } } else { if(StartDriverMode(NULL) == false) { // nothing } } } }
bool ejectDriveUDisks2(TDEStorageDevice* sdevice) { #ifdef WITH_UDISKS2 TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); if (dbusConn.isConnected()) { TQString blockDeviceString = sdevice->deviceNode(); blockDeviceString.replace("/dev/", ""); blockDeviceString = "/org/freedesktop/UDisks2/block_devices/" + blockDeviceString; TQT_DBusProxy hardwareControl("org.freedesktop.UDisks2", blockDeviceString, "org.freedesktop.DBus.Properties", dbusConn); if (hardwareControl.canSend()) { // get associated udisks2 drive path TQT_DBusError error; TQValueList<TQT_DBusData> params; params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Block") << TQT_DBusData::fromString("Drive"); TQT_DBusMessage reply = hardwareControl.sendWithReply("Get", params, &error); if (error.isValid()) { // Error! printf("[ERROR][tdehwlib] ejectDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); return FALSE; } else { if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { TQT_DBusObjectPath driveObjectPath = reply[0].toVariant().value.toObjectPath(); if (!driveObjectPath.isValid()) { return FALSE; } error = TQT_DBusError(); TQT_DBusProxy driveInformation("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.DBus.Properties", dbusConn); // can eject? TQValueList<TQT_DBusData> params; params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Drive") << TQT_DBusData::fromString("Ejectable"); TQT_DBusMessage reply = driveInformation.sendWithReply("Get", params, &error); if (error.isValid()) { // Error! printf("[ERROR][tdehwlib] ejectDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); return FALSE; } if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { bool ejectable = reply[0].toVariant().value.toBool(); if (!ejectable) { return FALSE; } // Eject the drive! TQT_DBusProxy driveControl("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.UDisks2.Drive", dbusConn); TQValueList<TQT_DBusData> params; TQT_DBusDataMap<TQString> options(TQT_DBusData::Variant); params << TQT_DBusData::fromStringKeyMap(options); TQT_DBusMessage reply = driveControl.sendWithReply("Eject", params, &error); if (error.isValid()) { // Error! printf("[ERROR][tdehwlib] ejectDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); return FALSE; } else { return TRUE; } } } } } } #endif // WITH_UDISKS2 return FALSE; }