Esempio n. 1
0
QList<DpySpec>
fetchSessions(int flags)
{
    QList<DpySpec> sessions;
    DpySpec tsess;

    gSet(1);
    gSendInt(G_List);
    gSendInt(flags);
  next:
    while (!(tsess.display = qString(gRecvStr())).isEmpty()) {
        tsess.from = qString(gRecvStr());
#ifdef HAVE_VTS
        tsess.vt = gRecvInt();
#endif
        tsess.user = qString(gRecvStr());
        tsess.session = qString(gRecvStr());
        tsess.flags = gRecvInt();
        if ((tsess.flags & isTTY) && !tsess.from.isEmpty())
            for (int i = 0; i < sessions.size(); i++)
                if (!sessions[i].user.isEmpty() &&
                    sessions[i].user == tsess.user &&
                    sessions[i].from == tsess.from)
                {
                    sessions[i].count++;
                    goto next;
                }
        tsess.count = 1;
        sessions.append(tsess);
    }
    gSet(0);
    return sessions;
}
Esempio n. 2
0
//////////////////////////////////////////////////////////////////////////////
// WMIReferenceProvider::getReferenceQueryString - calls the BaseProvider method 
//		to build the query string from the input parameters
//
// ///////////////////////////////////////////////////////////////////////////
String WMIReferenceProvider::getReferenceQueryString(
		const CIMObjectPath &objectName, 
		const String &resultClass, 
		const String &role)
{
	String sQuery;

	sQuery = qString(Q_REFERENCES);

	return getQueryString(objectName, sQuery, String::EMPTY, resultClass, role);

}
//////////////////////////////////////////////////////////////////////////////
// WMIAssociatorProvider::getAssocQueryString - calls the BaseProvider method
//        to build the query string from the input parameters
//
// ///////////////////////////////////////////////////////////////////////////
String WMIAssociatorProvider::getAssocQueryString(
        const CIMObjectPath &objectName,
        const String &assocClass,
        const String &resultClass,
        const String &role,
        const String &resultRole)
{
    String sQuery;

    sQuery = qString(Q_ASSOCIATORS);

    return getQueryString(objectName, sQuery, assocClass,
        resultClass, role, resultRole);

}
//////////////////////////////////////////////////////////////////////////////
// WMIAssociatorProvider::associators
//
//    NOTE:  This method sets up the query string and then calls
//        WMIBaseProvider::execCIMQuery
//////////////////////////////////////////////////////////////////////////////
Array<CIMObject> WMIAssociatorProvider::associators(
        const String& nameSpace,
        const String& userName,
        const String& password,
        const CIMObjectPath& objectName,
        const String& assocClass,
        const String& resultClass,
        const String& role,
        const String& resultRole,
        Boolean includeQualifiers,
        Boolean includeClassOrigin,
        const CIMPropertyList& propertyList)
{
    String sQuery;
    String sQueryLanguage;

    Array<CIMObject> objects;

    PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIAssociatorProvider::associators()");

    sQueryLanguage = qString(Q_WQL);
    sQuery = getAssocQueryString(objectName,
                assocClass,
                resultClass,
                role,
                resultRole);

    objects = execCIMQuery(nameSpace,
                userName,
                password,
                sQueryLanguage,
                sQuery,
                propertyList,
                includeQualifiers,
                includeClassOrigin);

    PEG_METHOD_EXIT();

    return objects;
}
Esempio n. 5
0
QString QBluetoothSocketPrivate::peerName() const
{
	RHostResolver resolver;
	
	if(getSocketServer()->socketServer.Handle()== 0 || !iSocket || state != QBluetoothSocket::ConnectedState )
	    {
	    // need to return something anyway
	    return QString();
	    }
    TInt err = resolver.Open(getSocketServer()->socketServer, KBTAddrFamily, KBTLinkManager);
    if (err==KErrNone)
        {
        TNameEntry nameEntry;
        TBTSockAddr sockAddr;
        iSocket->RemoteName(sockAddr);
        TInquirySockAddr address(sockAddr);
        address.SetBTAddr(sockAddr.BTAddr());
        address.SetAction(KHostResName|KHostResIgnoreCache); // ignore name stored in cache
        err = resolver.GetByAddress(address, nameEntry);
        if(err == KErrNone)
          {
          TNameRecord name = nameEntry();
          QString qString((QChar*)name.iName.Ptr(),name.iName.Length());
          m_peerName = qString;
          }
        }
    resolver.Close();
    
    if(err != KErrNone)
        {
        // What is best? return an empty string or return the MAC address?
        // In Symbian if we can't get the remote name we usually replace it with the MAC address
        // but since Bluez implementation return an empty string we do the same here.
        return QString();
        }
    
    return m_peerName;
}
Esempio n. 6
0
void qDeclare::gatherVariables()
{
	/*qProgram * prog = dynamic_cast<qProgram*>(parent);
	if (prog)
	{
		vartype = VAR_GLOBAL;
		real_name = "_g_" + pretty_name;

		prog->globalvars[pretty_name] = this;

		return;
	}*/
	/*qSequence * seq = dynamic_cast<qSequence*>(parent);
	if (seq)
	{
		qFunction * fun = dynamic_cast<qFunction*>(seq->parent);
		if (fun)
		{
			// variable in arg list
			vartype = VAR_ARG;
			real_name = "_a_" + pretty_name;
			fun->variablesavail.push_back(this);
			return;
		}
	}*/
	// local var

	//qdtprintf("gathered '%s'\n", pretty_name.c_str());

	char nn[128];
	sprintf(nn, "_l_%08X_", this);
	vartype = VAR_LOCAL;
	real_name = qString(nn) + pretty_name;

	parent->variablesavail.push_back(this);
	
	qValue::gatherVariables();
}
// -----------------------------------------------------------------------------
// CSTSSEPrompt::DisplayPromptL
// Displays the prompt
// -----------------------------------------------------------------------------
//
void CSTSSEPrompt::DisplayPromptL(const TDesC& aPrompt)
{
    #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS
            HbDeviceDialog* dialog;
            dialog = new(ELeave) HbDeviceDialog();
            
            QVariantMap parameters;
            QString qString((QChar*)aPrompt.Ptr(),aPrompt.Length());
            parameters[QString(KMessageTextKey)] = qString;
            
            dialog->show("com.nokia.hb.devicemessagebox/1.0", parameters);
            
            delete dialog;
    #else
            
    iGlobalNote->ShowNoteL(
        iSynchronizer->iStatus,
        EAknGlobalConfirmationNote, 
        aPrompt);
    iSynchronizer->ExecuteL((TTimeIntervalMicroSeconds32) 0);
            
    #endif
}
Esempio n. 8
0
////////////////////////////////////////////////////////////////
//
// cimParamFromWMIParam
//
///////////////////////////////////////////////////////////////
CIMParameter cimParamFromWMIParam(
        const String& strParamName,
        CIMTYPE wmiType,
        const CComPtr<IWbemQualifierSet>& pQualifiers,
        Boolean includeQualifiers)
{
    // Need to convert the qualifiers, even if includeQualifiers is FALSE
    // still need to get "in" and "out", as a min
    CIMQualifierList qualifierList;
    if (pQualifiers)
    {
        WMIQualifierSet(pQualifiers).cloneTo(qualifierList);
    }
    
    // Check for a reference type, and get the reference class if necessary:
    String referenceClass = String::EMPTY;
    if (CIM_REFERENCE == wmiType)
    {
        // strip "ref:"
        Uint32 pos = qualifierList.find(CIMName("CIMTYPE"));

        if (PEG_NOT_FOUND != pos)
        {
            qualifierList.getQualifier(pos).getValue().get(referenceClass);

            //strip off "ref:" or, if not found, erase the whole string
            if ((pos = referenceClass.find(qString(Q_COLON))) != PEG_NOT_FOUND)
            {
                referenceClass.remove(0, pos + 1);
            }
        }
    }
    CIMName refClassName;
    if (0 != referenceClass.size())
    {
        refClassName = referenceClass;
    }

    // Check for Array type, and get the array size, if necessary:
    Boolean isArray = false;
    Uint32 arraySize = 0;
    if (wmiType & CIM_FLAG_ARRAY)
    {
        isArray = true;

        // If there is a MAX qualifier on this array, use it as the size:
        Uint32 pos = qualifierList.find(CIMName("MAX"));
        if (PEG_NOT_FOUND != pos)
        {
            qualifierList.getQualifier(pos).getValue().get(arraySize);
        }

        // remove the array flag from the type to get the base type:
        wmiType &= ~CIM_FLAG_ARRAY;
    }

    // NOTE: Currently no mapping of WMI "object" types, so this could 
    // throw if the param is of type "object" or other un-supported
    // WMI type:
    CIMType cimType;
    try
    {
        cimType = WMITypeToCIMType(wmiType);
    }
    catch (TypeMismatchException tme)
    {
        // Don't want method enumeration to fail, just because
        // we don't handle the type, so making this type "reference" 
        // for now and making the reference class name "UNKNOWN_TYPE":
        cimType = CIMTYPE_REFERENCE;
        refClassName = CIMName("UNKNOWN_TYPE");
    }
    
    // Build the CIMParameter:
    CIMParameter cimParam = CIMParameter(strParamName, 
                                         cimType,
                                         isArray,
                                         arraySize,
                                         refClassName);

    // Now, add the parameter's qualifiers ("in" and "out" as a minimum):
    addQualifiersToCIMParameter(qualifierList, cimParam, includeQualifiers);

    // Finally, return the newly created CIMParameter:
    return cimParam;
}
Esempio n. 9
0
WMIMethod::WMIMethod(const BSTR & name, 
                     const CComPtr<IWbemClassObject>& inParameters,
                     const CComPtr<IWbemClassObject>& outParameters,
                     IWbemQualifierSet * pQualifierSet,
                     Boolean includeQualifiers)
{
    CIMQualifierList    qualifierList;
    CComBSTR            bsName = name;
    CComVariant            vValue = NULL;
    CIMTYPE                returnValueType;
    HRESULT            hr;
    
    WMIQualifierSet(pQualifierSet).cloneTo(qualifierList);

    // Get method return value
    String referenceClass = String::EMPTY;

    CComBSTR propertyName = L"ReturnValue";

// modified to correct bug JAGaf25827  
// JAGaf25827 - new code begin
    if (outParameters)
    {
        hr = outParameters->Get(
            propertyName,  
            0, 
            &vValue, 
            &returnValueType, 
            NULL);
    }
    else
    {
        hr = WBEM_E_NOT_FOUND;
    }

    //    not found. Maybe it is a 'void' return value
    if (hr == WBEM_E_NOT_FOUND) {
        vValue = NULL;
        returnValueType = CIM_UINT32; 
    }
    else if (hr != WBEM_S_NO_ERROR) {
        // Error: throw?
        throw Exception("WMIMethod::WMIMethod Get ReturnValue Failed.");
    }
    vValue.Clear();

    // the WMI 'CIMTYPE' qualifier stores a string that contains the reference
    // class name cimtype_qualifier ::= ["ref:" + <reference_class_name>]
    // NOTE: CIMMethod does not seem to store the reference class anywhere, 
    // but it seems like it should, so this code is here in case a reference 
    // class member is ever added to the CIMMethod class in the future:
    if (CIM_REFERENCE == returnValueType)
    {
        // strip "ref:"
        Uint32 pos = qualifierList.find(CIMName("CIMTYPE"));

        if (PEG_NOT_FOUND != pos)
        {
            qualifierList.getQualifier(pos).getValue().get(referenceClass);

            //strip off "ref:" or, if not found, erase the whole string
            if ((pos = referenceClass.find(qString(Q_COLON))) != PEG_NOT_FOUND)
            {
                referenceClass.remove(0, pos + 1);
            }
        }
    }

    String classOrigin = String::EMPTY;

    // the 'Propagated" qualifier stores a string containing the class origin
    // propagated qualifier ::= [<class_origin>"."]<method_name>
    {
        Uint32 pos = qualifierList.find(CIMName("Propagated"));

        if (PEG_NOT_FOUND != pos)
        {
            qualifierList.getQualifier(pos).getValue().get(classOrigin);

            // strip on the ".<method_name> portion if there...
            if ((pos = classOrigin.find(".")) != PEG_NOT_FOUND)
            {
                classOrigin.remove(pos);
            }
        }
    }

    // NOTE: Currently no mapping of WMI "object" types, so this could 
    // throw if the param is of type "object" or other un-supported
    // WMI type:
    CIMType cimType;
    try
    {
        cimType = WMITypeToCIMType(returnValueType);
    }
    catch (TypeMismatchException tme)
    {
        // Don't want method enumeration to fail, just because
        // we don't handle the type, so making this type "reference" 
        // for now and making the reference class name "UNKNOWN_TYPE":
        cimType = CIMTYPE_REFERENCE;
        referenceClass = "UNKNOWN_TYPE";
    }

    // Build the method
    CIMName cimRef;
    CIMName cimClsOrigin;
    BSTR tmpBstr = (BSTR)bsName.Copy();
    String s(_bstr_t(tmpBstr, FALSE));
    SysFreeString(tmpBstr);
    bsName.Empty();

    if (0 != referenceClass.size())
    {
        cimRef = referenceClass;
    }

    if (0 != classOrigin.size())
    {
        cimClsOrigin = classOrigin;
    }

    *this = CIMMethod(
        CIMName(s), 
        cimType,
        cimClsOrigin, 
        (classOrigin.size() != 0));


    // Add the qualifiers
    if (includeQualifiers)
    {
        Uint32 i, n;

        for (i = 0, n = qualifierList.getCount(); i < n; i++)
        {
            addQualifier(qualifierList.getQualifier(i));
        }
    }

    // Enumerate the parameters of the WMI method in and out classes here, 
    // adding them to the CIMMethos as appropriate.
    // NOTE: In WMI parameters method parameters are defined as in, out, or 
    // both, meaning that they cold show up in both the inParameters and 
    // outParameters lists. The addWMIParametersToCIMMethod() function will 
    // check for the existing parameters by name, and will not attempt to 
    // re-add any existing params (there is no need, since the "in" and "out"
    // versions of an in/out param are simply identical copies)
    addWMIParametersToCIMMethod(outParameters, *this, includeQualifiers);
    addWMIParametersToCIMMethod(inParameters, *this, includeQualifiers);
}
Esempio n. 10
0
//////////////////////////////////////////////////////////////////////////////
// WMIBaseProvider::getObjectName - extracts the String object name from
//		CIMObjectPath
//		removes namespace
// 
// Possible input Object Path formats: 
// 1. Fully-qualified path 
//     example: \\hostname:port\root\cimv2:ClassName.Key1="Value",Key2="Value" 
// 
// 2. No hostname & port (implies current host) 
//     example: root\cimv2:ClassName.Key1="Value",Key2="Value" 
// 
// 3. No namespace (implies current namespace): 
//     example: ClassName.Key1="Value",Key2="Value" 
// 
// 4. Reference instance 
//     example: ClassName.Key1=R"root\cimv2:RefClass.Key="RefValue"" 
// 
// In all cases, this method needs to return only the class name and keys from 
// the input object path (need to strip any hostname, port, and namespace). 
// For example, the return for cases #1-3, above, should be: 
//    ClassName.Key1="Value",Key2="Value" 
// 
// Also, for "reference" keys, the reference indicator (R) needs to be removed. 
// Therefore, the output from case #4, above, would be: 
//    ClassName.Key1="root\cimv2:RefClass.Key="RefValue"" 
// 
// ///////////////////////////////////////////////////////////////////////////
String WMIBaseProvider::getObjectName( const CIMObjectPath& objectName)
{
	String sObjName;
	String sObjNameLower;	
	bool bHaveReference = false;
	
	PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIBaseProvider::getObjectName()");

	sObjName = objectName.toString();			
	sObjNameLower = sObjName;
	sObjNameLower.toLower();
		
	Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
		"WMIBaseProvider::getObjectName() - ObjectName: %s", 
        sObjName.getCString()); 		

	Uint32 pos;

	// 1. if Object name initiates with a hostname then remove it
	if ((sObjName.subString(0, 4) != "root") && 
        (sObjNameLower.subString(0, 2) != "//") && 
        (sObjNameLower.subString(0, 2) != "\\\\"))
	{
		pos = sObjNameLower.find("root");

		if (sObjNameLower.find("=") > pos) {
				
		    if (PEG_NOT_FOUND != pos)
		    {
			    sObjName.remove(0, pos);
     			sObjNameLower.remove(0, pos);
		    }
        } 
    }

	//2. Remove the machine name and port if it exists
	if ((sObjNameLower.subString(0, 2) == "//") || 
        (sObjNameLower.subString(0, 2) == "\\\\"))
	{			
		pos = sObjNameLower.find("root");
		
		if (PEG_NOT_FOUND != pos)
		{
			sObjName.remove(0, pos);
			sObjNameLower.remove(0, pos);
		}

		//3. After ensuring that all stuff before root was removed,
		//   get the class/instance name.
		pos = sObjName.find(qString(Q_COLON));
			
		if (PEG_NOT_FOUND != pos)
		{			
			sObjName.remove(0, pos + 1);	
		}
	}
	else
	{		
		//   get the class/instance name.
		if (sObjNameLower.subString(0, 4) == "root")	
		{
			pos = sObjName.find(qString(Q_COLON));
			
			if (PEG_NOT_FOUND != pos)
			{			
				sObjName.remove(0, pos + 1);	
			}
		}
	}

	//4. Check if has =R".." for a reference instance and
	//	if so, remove the R
	//Uint32 pos = sObjName.find(qString(Q_REF_KEY));
	pos = sObjName.find(qString(Q_REF_KEY));
	bHaveReference = (PEG_NOT_FOUND != pos);

	if (bHaveReference)
	{
		while (PEG_NOT_FOUND != pos)
		{
			sObjName.remove(pos + 1, 1);	//removing R"
			pos = sObjName.find(qString(Q_REF_KEY));
		}
	}

	Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
		"WMIBaseProvider::getObjectName() - ObjectName: %s", 
        sObjName.getCString()); 		
	
	PEG_METHOD_EXIT();

	return sObjName;
}
Esempio n. 11
0
//////////////////////////////////////////////////////////////////////////////
// WMIBaseProvider::getQueryString - builds the query string from the
//		input parameters for Associator and Reference commands
//
// ///////////////////////////////////////////////////////////////////////////
String WMIBaseProvider::getQueryString(const CIMObjectPath &objectName,
		const String &sQueryCommand,							   
		const String &assocClass, 
		const String &resultClass, 
		const String &role,
		const String &resultRole)
{
	bool hasWHERE = false;
	bool isInst;

	//first we need to get the object name
	String sObjName = getObjectName(objectName);

	// check if is an instance name
	Uint32 pos = sObjName.find(qString(Q_PERIOD));
	isInst = (PEG_NOT_FOUND != pos);

	CMyString sQuery;
	sQuery.Format(CMyString(sQueryCommand), 128, CMyString(sObjName));

	//set up any optional parameters
	if (!((0 == assocClass.size()) && (0 == resultClass.size()) &&
		  (0 == role.size()) && (0 == resultRole.size())))
	{	
		// we have optional parameters, append the appropriate ones
		sQuery += qChar(Q_WHERE);
		hasWHERE = true;

		if (0 != assocClass.size())
		{
			sQuery += qChar(Q_ASSOC_CLS);
			sQuery += assocClass;
		}

		if (0 != resultClass.size())
		{
			sQuery += qChar(Q_RESULT_CLASS);
			sQuery += resultClass;
		}

		if (0 != role.size())
		{
			sQuery += qChar(Q_ROLE);
			sQuery += role;
		}

		if (0 != resultRole.size())
		{
			sQuery += qChar(Q_RESULT_ROLE);
			sQuery += resultRole;
		}
	}

	// check if an instance
	if (!isInst)
	{
		// have a class, add "SchemaOnly"
		if (!hasWHERE)
		{
			sQuery += qChar(Q_WHERE);
		}

		sQuery += qChar(Q_SCHEMA);
	}

	Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
		"WMIBaseProvider::getQueryString() - Query is %s", (LPCTSTR)sQuery); 

	String s = (LPCTSTR)sQuery;
	return s;
}
Esempio n. 12
0
WMIProperty::WMIProperty(const BSTR & name, 
						 const VARIANT & value, 
						 const CIMTYPE type, 
						 IWbemQualifierSet * pQualifierSet,
						 Boolean includeQualifiers)
{
	CIMQualifierList qualifierList;
	CComBSTR bsName = name;
	CComVariant vValue = value;
	qualifierList = WMIQualifierSet(pQualifierSet);

	// get additional property information
	String referenceClass = String::EMPTY;

	// the WMI 'CIMTYPE' qualifier stores a string that contains the reference class name
	// cimtype_qualifier ::= ["ref:" + <reference_class_name>]
	if (CIM_REFERENCE == type)
	{
	// strip "ref:"
		Uint32 pos = qualifierList.find(CIMName("CIMTYPE"));

		if (PEG_NOT_FOUND != pos)
		{
			qualifierList.getQualifier(pos).getValue().get(referenceClass);

			//strip off "ref:" or, if not found, erase the whole string
			if ((pos = referenceClass.find(qString(Q_COLON))) != PEG_NOT_FOUND)
			{
				referenceClass.remove(0, pos + 1);
			}
		}
	}

	String classOrigin = String::EMPTY;

	// the 'Propagated" qualifier stores a string containing the class origin
	// propagated qualifier ::= [<class_origin>"."]<property_name>
	{
		Uint32 pos = qualifierList.find(CIMName("Propagated"));

		if (PEG_NOT_FOUND != pos)
		{
			qualifierList.getQualifier(pos).getValue().get(classOrigin);

			// strip on the ".<property_name> portion if there...
			if ((pos = classOrigin.find(".")) != PEG_NOT_FOUND)
			{
				classOrigin.remove(pos);
			}
		}
	}

	// build the property
	BSTR tmpBstr = (BSTR)bsName.Copy();
	String s(_bstr_t(tmpBstr, FALSE));
	SysFreeString(tmpBstr);
    // old way -- memory leak?:
	// String s = WMIString(bsName);
	CIMName cimRef;
	CIMName cimClsOrigin;

	if (0 != referenceClass.size())
	{
		cimRef = referenceClass;
	}

	if (0 != classOrigin.size())
	{
		cimClsOrigin = classOrigin;
	}

	*this = CIMProperty(CIMName(s), WMIValue(vValue, type), 0, cimRef,
				cimClsOrigin, (classOrigin.size() != 0));

	vValue.Clear();

	// add the qualifiers
	if (includeQualifiers)
	{
		Uint32 i, n;

		for (i = 0, n = qualifierList.getCount(); i < n; i++)
		{
			addQualifier(qualifierList.getQualifier(i));
		}
	}

}