コード例 #1
0
ファイル: btlauncherAPI.cpp プロジェクト: beride/btlauncher
FB::VariantList btlauncherAPI::stopRunning(const std::string& val) {
	FBLOG_INFO("stopRunning()", "START");
	FBLOG_INFO("stopRunning()", val.c_str());
	FB::VariantList list;
    bool foundIt = false;

    size_t procCount = 0;
    kinfo_proc *procList = NULL;
    GetBSDProcessList(&procList, &procCount);
    size_t i;
    for (i = 0; i < procCount; i++) {
        if (!strcmp(procList[i].kp_proc.p_comm, val.c_str())) {
			FBLOG_INFO("stopRunning()", val.c_str());
            kill(procList[i].kp_proc.p_pid, SIGKILL);
            foundIt = true;
        }
    }

	free(procList);
	
    if (foundIt) {
        list.push_back("ok");
	} else {
        list.push_back("could not open process");
	}
	FBLOG_INFO("stopRunning()", "END");
    return list;
}
コード例 #2
0
FB::variant jsonValueToVariant( Json::Value root )
{
    Json::Value def;
    if (root.isString())
        return root.asString();
    else if (root.isBool())
        return root.asBool();
    else if (root.isDouble())
        return root.asDouble();
    else if (root.isInt())
        return root.asInt();
    else if (root.isUInt())
        return root.asUInt();
    else if (root.isNull())
        return FB::FBNull();
    else if (root.isArray()) {
        FB::VariantList outList;
        for (size_t i = 0; i < root.size(); ++i) {
            outList.push_back(jsonValueToVariant(root.get(i, def)));
        }
        return outList;
    } else if (root.isObject()) {
        Json::Value::Members members = root.getMemberNames();
        FB::VariantMap outMap;
        for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
        {
            outMap[*it] = jsonValueToVariant(root.get(*it, def));
        }
        return outMap;
    } else {
        return FB::FBVoid();
    }
}
コード例 #3
0
void DialogManagerX11::_showFolderDialog(FB::PluginWindow* win, bool multi, const PathCallback& cb)
{
    FB::VariantList out;

    // Create the dialog.  Do it the hard way so we can override the default
    // behavior which does not allow files and directories to be selected together.
    GtkWidget *dialog = gtk_dialog_new_with_buttons("Open", NULL, GTK_DIALOG_MODAL,
      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
    GtkWidget *action_area = gtk_dialog_get_action_area(GTK_DIALOG(dialog));
    GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));

    // Some nicer formatting
    gtk_box_set_spacing(GTK_BOX(content_area), 2);
    gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
    gtk_container_set_border_width(GTK_CONTAINER(action_area), 5);
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);

    // Create the file chooser widget
    GtkWidget *chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
    if (multi)
      gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(chooser), TRUE);

    // And add it to the dialog
    gtk_container_add(GTK_CONTAINER(content_area), chooser);
    gtk_widget_show(chooser);

    // for the life of me I can't figure out how to get the filechooserwidget
    // to return an actual requested size.  Going with the simple hard coded
    // size until that can be figured out.
    gtk_window_resize(GTK_WINDOW(dialog), 600, 400);

    // run the dialog
    gint result = gtk_dialog_run(GTK_DIALOG(dialog));
    if (result == GTK_RESPONSE_ACCEPT) {
      char *buffer;
      std::string filename;
      GSList *filenames, *iterator;

      filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(chooser));
      iterator = filenames;
      while (iterator) {
          buffer = (char *)g_slist_nth_data(iterator, 0);
          filename = std::string(buffer);
          g_free(buffer);

          // append a trailing slash if the name is a directory
          if (fs::is_directory(filename))
            filename.push_back('/');

          out.push_back(filename);
          iterator = g_slist_next(iterator);
      }
      g_slist_free(filenames);
    }
    gtk_widget_destroy(dialog);

    // call the callback with the results
    cb(out);
}
コード例 #4
0
FB::VariantList HPCCSystemsGraphViewControlAPI::getPropertiesForItems(const std::vector<int> & items)
{
	FB::VariantList retVal;
	for(std::vector<int>::const_iterator itr = items.begin(); itr != items.end(); ++itr)
		retVal.push_back(getProperties(*itr));

	return retVal;
}
コード例 #5
0
ファイル: JSArray.cpp プロジェクト: Ankso/FireBreath
FB::VariantList FB::JSArray::Values()
{
    FB::VariantList output;
    for (size_t i = 0; i < GetLength(); i++) {
        output.push_back((*this)[i]);
    }
    return output;
}
コード例 #6
0
FB::VariantList FBTestPluginAPI::reverseArray(const std::vector<std::string>& arr)
{
    FB::VariantList outArr;
    for (std::vector<std::string>::const_reverse_iterator it = arr.rbegin(); it != arr.rend(); it++)
    {
        outArr.push_back(*it);
    }
    return outArr;
}
コード例 #7
0
FB::VariantList HPCCSystemsGraphViewControlAPI::getVertices()
{
 	FB::VariantList items;
	std::vector<int> vertices;
	getPlugin()->GetVertices(vertices);
	for(std::vector<int>::const_iterator itr = vertices.begin(); itr != vertices.end(); ++itr)
		items.push_back(*itr);

	return items;
}
コード例 #8
0
ファイル: btlauncherAPI.cpp プロジェクト: bbarrows/btlauncher
FB::VariantList btlauncherAPI::stopRunning(const std::wstring& val) {
	FB::VariantList list;
	if (wcsstr(val.c_str(), _T(BT_HEXCODE)) || wcsstr(val.c_str(), _T(BTLIVE_CODE))) {
		HWND hWnd = FindWindow( val.c_str(), NULL );
		DWORD pid;
		DWORD parent;
		parent = GetWindowThreadProcessId(hWnd, &pid);
		HANDLE pHandle = OpenProcess(PROCESS_TERMINATE, NULL, pid);
		if (! pHandle) {
			list.push_back("could not open process");
			list.push_back(GetLastError());
		} else {
			BOOL result = TerminateProcess(pHandle, 0);
			list.push_back("ok");
			list.push_back(result);
		}
	}
	return list;
}
コード例 #9
0
FB::VariantList HPCCSystemsGraphViewControlAPI::getSelectionAsGlobalID()
{
	FB::VariantList retVal;

	std::vector<std::string> selectedItems;
	getPlugin()->GetSelection(selectedItems);
	for(std::vector<std::string>::const_iterator itr = selectedItems.begin(); itr != selectedItems.end(); ++itr)
		retVal.push_back(*itr);

	return retVal;
}
コード例 #10
0
FB::VariantList FBTestPluginAPI::getObjectValues(const FB::JSObjectPtr& arr)
{
    FB::VariantList outArr;
    std::map<std::string, FB::variant> inMap;
    arr->GetObjectValues(arr, inMap);

    for (std::map<std::string, FB::variant>::iterator it = inMap.begin(); it != inMap.end(); it++) {
        outArr.push_back(it->second);
    }
    return outArr;
}
コード例 #11
0
FB::VariantList HPCCSystemsGraphViewControlAPI::find(const std::string & text, boost::optional<bool> includeProperties)
{
	assert(getPlugin());
	FB::VariantList retVal;

	std::vector<int> foundItems;
	getPlugin()->Find(text, includeProperties ? *includeProperties : true, foundItems);
	for(std::vector<int>::const_iterator itr = foundItems.begin(); itr != foundItems.end(); ++itr)
		retVal.push_back(*itr);

	return retVal;
}
コード例 #12
0
FB::VariantMap FBTestPluginAPI::getUserData()
{
    FB::VariantMap map;
    map["Name"] = "Richard Bateman";
    map["Location"] = "Somewhere in Utah";
    map["EyeColor"] = "Hazel";
    map["HairColor"] = "Brown";
    FB::VariantList kids;
    kids.push_back("Caleb");
    kids.push_back("Unknown");
    kids.push_back("Ok, I only have one, but I'm filling space");
    FB::VariantMap innerMap;
    innerMap["test"] = 12;
    innerMap["test2"] = true;
    innerMap["test3"] = 12.4;
    innerMap["test4"] = "asdf";
    map["inner"] = innerMap;
    kids.push_back(innerMap);
    map["Kids"] = kids;
    return map;
}
コード例 #13
0
FB::VariantList FBTestPluginAPI::getUserArray()
{
    FB::VariantList map;
    map.push_back("Richard Bateman");
    map.push_back("Somewhere in Utah");
    map.push_back("Hazel");
    map.push_back("Brown");
    FB::VariantList kids;
    kids.push_back("Caleb");
    kids.push_back("Unknown");
    kids.push_back("Ok, I only have one, but I'm filling space");
    FB::VariantMap innerMap;
    innerMap["test"] = 12;
    innerMap["test2"] = true;
    innerMap["test3"] = 12.4;
    innerMap["test4"] = "asdf";
    map.push_back(innerMap);
    kids.push_back(innerMap);
    map.push_back(kids);
    return map;
}
コード例 #14
0
ファイル: btlauncherAPI.cpp プロジェクト: beride/btlauncher
FB::VariantList btlauncherAPI::isRunning(const std::string& val) {
	FBLOG_INFO("isRunning()", "START");
	FB::VariantList list;
    size_t procCount = 0;
	kinfo_proc *procList = NULL;
	GetBSDProcessList(&procList, &procCount);
	size_t i;
	for (i = 0; i < procCount; i++) {
		if (!strcmp(procList[i].kp_proc.p_comm, val.c_str())) {
			FBLOG_INFO("isRunning()", val.c_str());
			list.push_back(procList[i].kp_proc.p_comm);
		}
	}
	
	free(procList);
	
	FBLOG_INFO("isRunning()", "END");
	return list;
}
コード例 #15
0
ファイル: UploadQueue.cpp プロジェクト: letolabs/FireBreath
FB::VariantMap UploadQueue::getStatusDict(bool include_filenames) {
    FB::VariantMap d;
    // whole-queue stats
    d["queue_name"] = name;
    d["current_queue_bytes_remaining"] = current_queue_bytes;
    d["total_queue_bytes"] = total_queue_bytes;
    d["total_queue_files"] = total_queue_files;
    d["current_queue_files_remaining"] = files_waiting;
    d["batches_remaining"] = ceil(static_cast<float>(files_waiting) / static_cast<float>(batch_size));
    d["status"] = "Uploading";

    // this-batch stats
    if (include_filenames) {
        FB::VariantList cf;
        for (std::set<std::wstring>::const_iterator it = current_upload_files.begin();
            it != current_upload_files.end(); ++it)  {
                cf.push_back(*it);
        }
        d["current_files"] = cf;
    }
    d["current_batch_bytes_total"] = current_batch_bytes;

    double current_batch_pct_complete = 0.0;

    if (current_upload_request) {
        HTTP::Status st = current_upload_request->getStatus();
        FB::VariantMap status(st.asDict());
        d.insert(status.begin(), status.end());
        if (st.send_total) {
            current_batch_pct_complete = static_cast<double>(st.bytes_sent)
                / static_cast<double>(st.send_total);
        }
    }

    d["current_batch_pct_complete"] = current_batch_pct_complete;
    d["overall_progress_pct"] = static_cast<double>(
        (total_queue_bytes - (current_queue_bytes + current_batch_bytes))
            + (current_batch_pct_complete *  current_batch_bytes))
        / static_cast<double>(total_queue_bytes);

    return d;
}