Example #1
0
FatalError::FatalError (char const* message, char const* fileName, int lineNumber)
{
    typedef CriticalSection LockType;

    static LockType s_mutex;

    std::lock_guard <LockType> lock (s_mutex);

    String const backtraceString = SystemStats::getStackBacktrace ();

    char const* const szStackBacktrace = backtraceString.toRawUTF8 ();

    String const fileNameString = fileName;

    char const* const szFileName = fileNameString.toRawUTF8 ();

    Reporter* const reporter (s_reporter);

    if (reporter != nullptr)
    {
        reporter->onFatalError (message, szStackBacktrace, szFileName, lineNumber);
    }

    Process::terminate ();
}
void DiauproPluginAudioProcessor::handleAsyncUpdate ()
{

    if (editor != nullptr && editorReady) {
        
        vcoRtTime = diauproVCOProcessor.getRoundTripTime();
        vcoProcessTime = diauproVCOProcessor.getProcessTime() ;
        vcoRtMaxTime = jmax(vcoRtMaxTime, vcoRtTime);
        if (vcoRtTime > 0.0) vcoRtMinTime = jmin(vcoRtMinTime, vcoRtTime);
        vcoNetStatus = diauproVCOProcessor.hasActiveNetworkConnection();
        
        vcaRtTime = diauproVCAProcessor.getRoundTripTime();
        vcaProcessTime = diauproVCAProcessor.getProcessTime() ;
        vcaRtMaxTime = jmax(vcaRtMaxTime, vcaRtTime);
        if (vcaRtTime > 0.0) vcaRtMinTime = jmin(vcaRtMinTime, vcaRtTime);
        vcaNetStatus = diauproVCAProcessor.hasActiveNetworkConnection();
        
        nullRtTime = diauproNullProcessor.getRoundTripTime();
        nullProcessTime = diauproNullProcessor.getProcessTime() ;
        nullRtMaxTime = jmax(nullRtMaxTime, nullRtTime);
        if (nullRtTime > 0.0) nullRtMinTime = jmin(nullRtMinTime, nullRtTime);
        nullNetStatus = diauproNullProcessor.hasActiveNetworkConnection();
        
        if(((DiauproPluginAudioProcessorEditor *)editor)->isReady()) editor->repaint ();
        
        //nullNetStatus, nullAsync, nullRtTime, nullProcessTime
        String log = String::formatted("%d,%d,%f,%f\n", nullNetStatus, nullAsync, nullRtTime, nullProcessTime );
        logfile->write(log.toRawUTF8(), log.length()  );
    }
}
void AppsPageComponent::focusApp(AppIconButton* appButton, const String& windowId) {
  DBG("AppsPageComponent::focusApp - " << appButton->shell);
  String focusShell = "echo 'focus_client_by_window_id("+windowId+")' | awesome-client";
  StringArray focusCmd{"sh", "-c", focusShell.toRawUTF8()};
  ChildProcess focusWindow;
  focusWindow.start(focusCmd);
};
Example #4
0
ID3DBlob* D3D11Context::compileShaderFromBinaryData (const char* id, const char* entry, const char* target)
{
    String fileId = String (id).replaceCharacter ('.', '_');
    int dataSize;
    const char* data = BinaryData::getNamedResource (fileId.toRawUTF8(), dataSize);

    if (nullptr == data)
        return nullptr;

    ShaderCompileDesc desc;
    desc.name = id;
    desc.entry = entry;
    desc.target = target;
    desc.source = data;
    desc.sourceSize = (size_t)dataSize;

    ShaderCompileResult ret = compileShader (desc);

    if (ret.errorMessage)
    {
        const char* str = (const char*)ret.errorMessage->GetBufferPointer();
        errLog (str);
        ret.errorMessage->Release();
    }

    return ret.byteCode;
}
int HDF5FileBase::createGroupIfDoesNotExist(String path)
{
	if (!opened) return -1;
	try {
		file->childObjType(path.toRawUTF8());
	}
	catch (FileIException)
	{
		return createGroup(path);
	}
	return 0;
}
void PanelEngine::updateUIEnveloppe(const char* paramName) {
    const char** pointName = enveloppe[0]->getPointSuffix();
    for (int k=0; k<NUMBER_OF_OPERATORS; k++) {
        const char* pString = enveloppe[k]->getName().toRawUTF8();

        for (int p=2; p < enveloppe[k]->getNumberOfPoints() * 2; p++) {
            String name = String(pString) + String(pointName[p - 2]);

            if (paramName != nullptr && name != String(paramName)) {
                continue;
            }

            teragon::Parameter* paramToMap =  parameterSet->get(name.toRawUTF8());
            // Will remove that later but dont' BUG for the moment if that doesn't fit
            if (paramToMap == nullptr) {
                printf("Enveloppe point %s does not exist...\r\n", name.toRawUTF8());
                return;
            }

            if (panelParameterMap[name] == nullptr) {
                panelParameterMap.set(name ,paramToMap);
            }
            // And let's update the value and update the UI Without sending modification !!!
            // No modification : we dont want sliderValueChanged to be called in the different panels
            if ((p & 0x1) == 0) {
                if (paramToMap->getValue() != enveloppe[k]->getX(p / 2)) {
                    enveloppe[k]->setX(p / 2, paramToMap->getValue());
                    enveloppe[k]->repaint();

                }
            } else {
                if (paramToMap->getValue() != enveloppe[k]->getY(p / 2)) {
                    enveloppe[k]->setY(p / 2, paramToMap->getValue());
                    enveloppe[k]->repaint();
                }
            }
        }
    }
}
Example #7
0
void jojo_bang (t_jojo *x)
{
    const ScopedLock myLock (x->lock_); 
    
    post ("Public / %s", x->public_.toString().toRawUTF8());
    post ("Private / %s", x->private_.toString().toRawUTF8());
    
    String myText (CharPointer_UTF8 ("P\xc3\xa9p\xc3\xa9 p\xc3\xa8te en ao\xc3\xbbt!"));
    
    post ("%s", myText.toRawUTF8());
    
    const juce::MemoryBlock blockBegin (myText.toRawUTF8(), myText.getNumBytesAsUTF8() + 1);

    BigInteger bitArray;
    bitArray.loadFromMemoryBlock (blockBegin);
    x->public_.applyToValue (bitArray);             /* Encrypt with the public key. */

    post ("%s", bitArray.toString (16).toRawUTF8());
    
    x->private_.applyToValue (bitArray);            /* Then decrypt with the private key. */
    
    const juce::MemoryBlock blockEnd (bitArray.toMemoryBlock());
    post ("%s", blockEnd.toString().toRawUTF8());
}
Example #8
0
bool Tunefish4AudioProcessor::loadProgram(eU32 index)
{
    String path = pluginLocation +
    File::separatorString + String("tf4programs") + File::separatorString +
    String("program") + String(index) + String(".txt");

    File file(path);
    FileInputStream *stream = file.createInputStream();
    if (!stream)
        return false;

    String name = stream->readNextLine();
    programs[index].setName(name.toRawUTF8());

    while(true)
    {
        String line = stream->readNextLine();

        if (line.length() == 0)
        {
            eDelete(stream);
            return true;
        }

        StringArray parts;
        parts.addTokens(line, ";", String::empty);

        if (parts.size() == 2)
        {
            String key = parts[0];
            eF32 value = parts[1].getFloatValue();

            for(eU32 i=0;i<TF_PARAM_COUNT;i++)
            {
                if (key == TF_NAMES[i])
                {
                    programs[index].setParam(i, value);
                    break;
                }
            }
        }
    }

    return true;
}
Image JUCE_API getIconFromApplication (const String& applicationPath, const int size)
{
    Image hostIcon;

    if (CFStringRef pathCFString = CFStringCreateWithCString (kCFAllocatorDefault, applicationPath.toRawUTF8(), kCFStringEncodingUTF8))
    {
        if (CFURLRef url = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, pathCFString, kCFURLPOSIXPathStyle, 1))
        {
            if (CFBundleRef appBundle = CFBundleCreate (kCFAllocatorDefault, url))
            {
                if (CFTypeRef infoValue = CFBundleGetValueForInfoDictionaryKey (appBundle, CFSTR("CFBundleIconFile")))
                {
                    if (CFGetTypeID (infoValue) == CFStringGetTypeID())
                    {
                        CFStringRef iconFilename = reinterpret_cast<CFStringRef> (infoValue);
                        CFStringRef resourceURLSuffix = CFStringHasSuffix (iconFilename, CFSTR(".icns")) ? nullptr : CFSTR("icns");
                        if (CFURLRef iconURL = CFBundleCopyResourceURL (appBundle, iconFilename, resourceURLSuffix, nullptr))
                        {
                            if (CFStringRef iconPath = CFURLCopyFileSystemPath (iconURL, kCFURLPOSIXPathStyle))
                            {
                                File icnsFile (CFStringGetCStringPtr (iconPath, CFStringGetSystemEncoding()));
                                hostIcon = getIconFromIcnsFile (icnsFile, size);
                                CFRelease (iconPath);
                            }

                            CFRelease (iconURL);
                        }
                    }
                }

                CFRelease (appBundle);
            }

            CFRelease (url);
        }

        CFRelease (pathCFString);
    }

    return hostIcon;
}
Example #10
0
void FatalError::Reporter::reportMessage (String& formattedMessage)
{
    std::cerr << formattedMessage.toRawUTF8 ();
}
Example #11
0
void FatalErrorReporter::reportMessage (String& formattedMessage)
{
    Log::out() << formattedMessage.toRawUTF8 ();
}
void WifiStatusNM::setConnectedAccessPoint(WifiAccessPoint *ap, String psk) {
  ScopedPointer<StringArray> cmd;

  for (const auto& listener : listeners)
    listener->handleWifiBusy();

  // disconnect if no ap provided
  if (ap == nullptr) {
    NMActiveConnection *conn = nm_device_get_active_connection(nmdevice);
    removeNMConnection(nmdevice, conn);

    return;
  }
  // try to connect to ap, dispatch events on success and failure
  else {
    NMConnection *connection = NULL;
    NMSettingWireless *s_wifi = NULL;
    NMSettingWirelessSecurity *s_wsec = NULL;
    const char *nm_ap_path = NULL;
    const GPtrArray *ap_list;
    NMAccessPoint *candidate_ap;

    //FIXME: expand WifiAccessPoint struct to know which NMAccessPoint it is
    ap_list = nm_device_wifi_get_access_points(NM_DEVICE_WIFI(nmdevice));
    if (ap_list == NULL)
      return;

    for (int i = 0; i < ap_list->len; i++) {
      const char *candidate_hash;
      candidate_ap = (NMAccessPoint *) g_ptr_array_index(ap_list, i);
      candidate_hash = utils_hash_ap(nm_access_point_get_ssid(candidate_ap),
                                     nm_access_point_get_mode(candidate_ap),
                                     nm_access_point_get_flags(candidate_ap),
                                     nm_access_point_get_wpa_flags(candidate_ap),
                                     nm_access_point_get_rsn_flags(candidate_ap));

      if (ap->hash == candidate_hash) {
        nm_ap_path = nm_object_get_path(NM_OBJECT(candidate_ap));
        break;
      }
    }

    if (!nm_ap_path)
      return;

    connecting = true;

    connection = nm_connection_new();
    s_wifi = (NMSettingWireless *) nm_setting_wireless_new();
    nm_connection_add_setting(connection, NM_SETTING(s_wifi));
    g_object_set(s_wifi,
                 NM_SETTING_WIRELESS_SSID, nm_access_point_get_ssid(candidate_ap),
                 NM_SETTING_WIRELESS_HIDDEN, false,
                 NULL);

    if (!psk.isEmpty()) {
      s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new();
      nm_connection_add_setting(connection, NM_SETTING(s_wsec));

      if (nm_access_point_get_wpa_flags(candidate_ap) == NM_802_11_AP_SEC_NONE &&
          nm_access_point_get_rsn_flags(candidate_ap) == NM_802_11_AP_SEC_NONE) {
        /* WEP */
        nm_setting_wireless_security_set_wep_key(s_wsec, 0, psk.toRawUTF8());
	if (isValidWEPKeyFormat(psk))
          g_object_set(G_OBJECT(s_wsec), NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE,
                       NM_WEP_KEY_TYPE_KEY, NULL);
	else if (isValidWEPPassphraseFormat(psk))
          g_object_set(G_OBJECT(s_wsec), NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE,
                       NM_WEP_KEY_TYPE_PASSPHRASE, NULL);
	else
	  DBG("User input invalid WEP Key type, psk.length() = " << psk.length()
              << ", not in [5,10,13,26]");
      } else {
        g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_PSK, psk.toRawUTF8(), NULL);
      }
    }

    nm_client_add_and_activate_connection(nmclient,
                                                connection,
                                                nmdevice,
                                                nm_ap_path,
                                                handle_add_and_activate_finish,
                                                this);
  }
}
Example #13
0
void Tunefish4AudioProcessor::changeProgramName (int index, const String& newName)
{
    eASSERT(index >= 0 && index < TF_PLUG_NUM_PROGRAMS);
    programs[index].setName(newName.toRawUTF8());
}
Example #14
0
 String addEscapeChars (const String& s)
 {
     MemoryOutputStream out;
     writeEscapeChars (out, s.toRawUTF8(), -1, -1, false, true, true);
     return out.toUTF8();
 }