// Take in JSON of value (bool) and handle (string) and return a message when complete std::string ClipboardNDK::setText(const std::string& inputString) { Json::Reader reader; Json::Value root; bool parse = reader.parse(inputString, root); if (!parse) { return "Cannot parse JSON object for Prevent Sleep"; } string arg=root["value"].asCString(); if (get_clipboard_can_write() == 0) { //could write clip board. //always empty clip board. empty_clipboard(); //write to the clip board int ret=set_clipboard_data("text/plain", arg.size(), arg.c_str()); stringstream ss; ss<<ret; return ss.str(); } else { return "-1"; } }
/* * set Text to clip board. */ int JsClipboard::setClipboardText(const std::string& arg) { if (get_clipboard_can_write() == 0) { //could write clip board. //always empty clip board.why ? API told me. empty_clipboard(); //write to the clip board int ret = set_clipboard_data("text/plain", arg.size(), arg.c_str()); return ret; } else { return -1; } }
void QBBClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) { if (mode != QClipboard::Clipboard) return; empty_clipboard(); // If data is null, this is equivalent to clearing the clipboard if (data == 0) return; QStringList format = data->formats(); for (int i = 0; i < format.size(); ++i) { QString type = format.at(i); QByteArray buf = data->data(type); int ret = set_clipboard_data(type.toUtf8().data(), buf.size(), buf.data()); #if defined(QBBCLIPBOARD_DEBUG) qDebug() << "QBB: set " << type.toUtf8().data() << "to clipboard, size=" << buf.size() << ";ret=" << ret; #endif } }