Ejemplo n.º 1
0
void CDB_ODBC_ConnParams::x_MapPairToParam(const string& key, const string& value)
{
    // MS SQL Server related attributes ...
    if (NStr::Equal(key, "SERVER", NStr::eNocase)) {
        SetServerName(value);
    } else if (NStr::Equal(key, "UID", NStr::eNocase)) {
        SetUserName(value);
    } else if (NStr::Equal(key, "PWD", NStr::eNocase)) {
        SetPassword(value);
    } else if (NStr::Equal(key, "DRIVER", NStr::eNocase)) {
        SetDriverName(value);
    } else if (NStr::Equal(key, "DATABASE", NStr::eNocase)) {
        SetDatabaseName(value);
    } else if (NStr::Equal(key, "ADDRESS", NStr::eNocase)) {
        string host;
        string port;

        NStr::SplitInTwo(value, ",", host, port);
        NStr::TruncateSpacesInPlace(host);
        NStr::TruncateSpacesInPlace(port);

        // SetHost(host);
        SetPort(static_cast<Uint2>(NStr::StringToInt(port)));
    } else {
        SetParam(key, value);
    }
}
nsDeviceContextSpecWin::~nsDeviceContextSpecWin()
{
  SetDeviceName(nsnull);
  SetDriverName(nsnull);
  SetDevMode(NULL);

  nsCOMPtr<nsIPrintSettingsWin> psWin(do_QueryInterface(mPrintSettings));
  if (psWin) {
    psWin->SetDeviceName(nsnull);
    psWin->SetDriverName(nsnull);
    psWin->SetDevMode(NULL);
  }

  // Free them, we won't need them for a while
  GlobalPrinters::GetInstance()->FreeGlobalPrinters();
}
Ejemplo n.º 3
0
hsG3DDeviceRecord& hsG3DDeviceRecord::operator=(const hsG3DDeviceRecord& src)
{
    fFlags = src.fFlags;

    SetG3DDeviceType(src.GetG3DDeviceType());
    SetG3DHALorHEL(src.GetG3DHALorHEL());

    SetDriverDesc(src.GetDriverDesc());
    SetDriverName(src.GetDriverName());
    SetDriverVersion(src.GetDriverVersion());
    SetDeviceDesc(src.GetDeviceDesc());

    fCaps = src.fCaps;
    fLayersAtOnce = src.fLayersAtOnce;
    fMemoryBytes = src.fMemoryBytes;
    fZBiasRating = src.fZBiasRating;
    fLODBiasRating = src.fLODBiasRating;
    fFogExpApproxStart = src.fFogExpApproxStart;
    fFogExp2ApproxStart = src.fFogExp2ApproxStart;
    fFogEndBias = src.fFogEndBias;

    fModes.SetCount(src.fModes.GetCount());
    int i;
    for( i = 0; i < fModes.GetCount(); i++ )
        fModes[i] = src.fModes[i];

    fFogKnees[ 0 ] = src.fFogKnees[ 0 ];
    fFogKnees[ 1 ] = src.fFogKnees[ 1 ];
    fFogKneeVals[ 0 ] = src.fFogKneeVals[ 0 ];
    fFogKneeVals[ 1 ] = src.fFogKneeVals[ 1 ];

    fAASetting = src.fAASetting;

    fMaxAnisotropicSamples = src.fMaxAnisotropicSamples;

    return *this;
}
//----------------------------------------------------------------------------------
NS_IMETHODIMP nsDeviceContextSpecWin::Init(nsIWidget* aWidget, 
                                           nsIPrintSettings* aPrintSettings,
                                           PRBool aIsPrintPreview)
{
  mPrintSettings = aPrintSettings;

  nsresult rv = aIsPrintPreview ? NS_ERROR_GFX_PRINTER_PRINTPREVIEW : 
                                  NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
  if (aPrintSettings) {
    nsCOMPtr<nsIPrintSettingsWin> psWin(do_QueryInterface(aPrintSettings));
    if (psWin) {
      PRUnichar* deviceName;
      PRUnichar* driverName;
      psWin->GetDeviceName(&deviceName); // creates new memory (makes a copy)
      psWin->GetDriverName(&driverName); // creates new memory (makes a copy)

      LPDEVMODEW devMode;
      psWin->GetDevMode(&devMode);       // creates new memory (makes a copy)

      if (deviceName && driverName && devMode) {
        // Scaling is special, it is one of the few
        // devMode items that we control in layout
        if (devMode->dmFields & DM_SCALE) {
          double scale = double(devMode->dmScale) / 100.0f;
          if (scale != 1.0) {
            aPrintSettings->SetScaling(scale);
            devMode->dmScale = 100;
          }
        }

        SetDeviceName(deviceName);
        SetDriverName(driverName);
        SetDevMode(devMode);

        if (!aIsPrintPreview) {
          rv = CheckForPrintToFile(mPrintSettings, deviceName, nsnull);
          if (NS_FAILED(rv)) {
            nsCRT::free(deviceName);
            nsCRT::free(driverName);
            return NS_ERROR_FAILURE;
          }
        }

        // clean up
        nsCRT::free(deviceName);
        nsCRT::free(driverName);

        return NS_OK;
      } else {
        PR_PL(("***** nsDeviceContextSpecWin::Init - deviceName/driverName/devMode was NULL!\n"));
        if (deviceName) nsCRT::free(deviceName);
        if (driverName) nsCRT::free(driverName);
        if (devMode) ::HeapFree(::GetProcessHeap(), 0, devMode);
      }
    }
  } else {
    PR_PL(("***** nsDeviceContextSpecWin::Init - aPrintSettingswas NULL!\n"));
  }

  // Get the Print Name to be used
  PRUnichar * printerName = nsnull;
  if (mPrintSettings) {
    mPrintSettings->GetPrinterName(&printerName);
  }

  // If there is no name then use the default printer
  if (!printerName || (printerName && !*printerName)) {
    printerName = GetDefaultPrinterNameFromGlobalPrinters();
  }

  NS_ASSERTION(printerName, "We have to have a printer name");
  if (!printerName || !*printerName) return rv;

  if (!aIsPrintPreview) {
    CheckForPrintToFile(mPrintSettings, nsnull, printerName);
  }
 
  return GetDataFromPrinter(printerName, mPrintSettings);
}
Ejemplo n.º 5
0
bool NetClient::SendDriverInfoPacket(NetDriver *pDriver)
{
    SetDriverName(pDriver->name);
    pDriver->address.port = m_pHost->address.port;

    GfLogTrace("SendDriverInfoPacket: pDriver\n");
    GfLogTrace("->host=%d\n", pDriver->address.host);
    GfLogTrace("->port=%d\n", pDriver->address.port);
    GfLogTrace("->idx=%d\n", pDriver->idx);
    GfLogTrace("->name=%s\n", pDriver->name);
    GfLogTrace("->sname=%s\n", pDriver->sname);
    GfLogTrace("->cname=%s\n", pDriver->cname);
    GfLogTrace("->car=%s\n", pDriver->car);
    GfLogTrace("->team=%s\n", pDriver->team);
    GfLogTrace("->author=%s\n", pDriver->author);
    GfLogTrace("->racenumber=%d\n", pDriver->racenumber);
    GfLogTrace("->skilllevel=%s\n", pDriver->skilllevel);
    GfLogTrace("->red=%.1f\n", pDriver->red);
    GfLogTrace("->green=%.1f\n", pDriver->green);
    GfLogTrace("->blue=%.1f\n", pDriver->blue);
    GfLogTrace("->module=%s\n", pDriver->module);
    GfLogTrace("->type=%s\n", pDriver->type);
    GfLogTrace("->client=%d\n", pDriver->client);

    PackedBuffer msg;

    try
    {
        msg.pack_ubyte(PLAYERINFO_PACKET);
        msg.pack_int(pDriver->idx);
        msg.pack_string(pDriver->name, sizeof pDriver->name);
        msg.pack_string(pDriver->sname, sizeof pDriver->sname);
        msg.pack_string(pDriver->cname, sizeof pDriver->cname);
        msg.pack_string(pDriver->car, sizeof pDriver->car);
        msg.pack_string(pDriver->team, sizeof pDriver->team);
        msg.pack_string(pDriver->author, sizeof pDriver->author);
        msg.pack_int(pDriver->racenumber);
        msg.pack_string(pDriver->skilllevel,
                sizeof pDriver->skilllevel);
        msg.pack_float(pDriver->red);
        msg.pack_float(pDriver->green);
        msg.pack_float(pDriver->blue);
        msg.pack_string(pDriver->module, sizeof pDriver->module);
        msg.pack_string(pDriver->type, sizeof pDriver->type);
        msg.pack_int(pDriver->client);
    }
//    catch (PackedBufferException &e)
    catch (PackedBufferException)
    {
        GfLogFatal("SendDriverInfoPacket: packed buffer error\n");
    }
    GfLogTrace("SendDriverInfoPacket: packed data length=%d\n",
            msg.length());

    ENetPacket * pPacket = enet_packet_create (msg.buffer(), 
            msg.length(), 
            ENET_PACKET_FLAG_RELIABLE);

    if (enet_peer_send (m_pServer, RELIABLECHANNEL, pPacket)==0)
        return true;

    return false;
}
Ejemplo n.º 6
0
CDBUriConnParams::CDBUriConnParams(const string& params)
{
    string::size_type pos = 0;
    string::size_type cur_pos = 0;

    // Check for 'dbapi:' ...
    pos = params.find_first_of(":", pos);
    if (pos == string::npos) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001);
    }

    if (! NStr::StartsWith(params, "dbapi:", NStr::eNocase)) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001);
    }

    cur_pos = pos + 1;

    // Check for driver name ...
    pos = params.find("//", cur_pos);
    if (pos == string::npos) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should contain driver name", 20001);
    }

    if (pos != cur_pos) {
        string driver_name = params.substr(cur_pos, pos - cur_pos - 1);
        SetDriverName(driver_name);
    }

    cur_pos = pos + 2;

    // Check for user name and password ...
    pos = params.find_first_of(":@", cur_pos);
    if (pos != string::npos) {
        string user_name = params.substr(cur_pos, pos - cur_pos);

        if (params[pos] == '@') {
            SetUserName(user_name);

            cur_pos = pos + 1;

            ParseServer(params, cur_pos);
        } else {
            // Look ahead, we probably found a host name ...
            cur_pos = pos + 1;

            pos = params.find_first_of("@", cur_pos);

            if (pos != string::npos) {
                // Previous value was an user name ...
                SetUserName(user_name);

                string password = params.substr(cur_pos, pos - cur_pos);
                SetPassword(password);

                cur_pos = pos + 1;
            }

            ParseServer(params, cur_pos);
        }
    } else {
        ParseServer(params, cur_pos);
    }

}