예제 #1
0
bool ClientController::DeleteClient(const Client &client)
{
    if(!(UserSingleton::GetInstance().GetPermissions() & PLM::PermissionsFlag::WRITE_CLIENTS))
    {
        return false;
    }

    QSqlQuery query = GetDb().CreateQuery();
    query.prepare("DELETE FROM \"Client\" WHERE \"ClientId\"=:clientId");
    query.bindValue(":clientId", client.GetClientId());

    if(!query.exec())
    {
        return false;
    }

    if(!DeleteContact(client))
    {
        return false;
    }

    qint32 clientId = client.GetClientId();
    RemoveClient(clientId);

    return true;
}
예제 #2
0
//-----------------------------------------------------------------------------
// Function:    PrintMenu
// Purpose:     Prints a menu, retrieves the user selection, calls the handler, loops.
//              Returns when "Quit" is selected from the menu
// Parameters:  None
//
void RunMenu()
{
    HRESULT hr;
    WCHAR wzBuff[INPUT_BUFSIZE];
    int nInput;

    // Continuously show the menu to user and respond to their request
    //
    while (TRUE)
    {
        PrintMenu();

        fflush(stdin);
        hr = StringCbGets(wzBuff, sizeof(wzBuff));

        if (FAILED(hr))
        {
            wprintf (L"Invalid input, expected a number between 1 and 25 or Q to quit.\n");
            continue;
        }

        if  ((wcsncmp(wzBuff, L"Q", INPUT_BUFSIZE) == 0) || (wcsncmp(wzBuff, L"q", INPUT_BUFSIZE) == 0))
        {
            // break out of while loop.
            //
            break;
        }

        // since wtoi can't distinguish between 0 and an error, note that valid values start at 1, not 0    
        nInput = _wtoi(wzBuff);
        if (nInput < 1  || nInput > 25)
        {
            printf ("Invalid input, expected a number between 1 and 25 or Q to quit.\n");
            continue;
        }

        switch (nInput)
        {
            case 1:
                SignIn();
                break;

            case 2:
                SignOut();
                break;

            case 3:
                SignInOptions();
                break;

            case 4:
                SetEndpointName();
                break;

            case 5:
                GetEndpointName();
                break;

            case 6:
                DisplayEndpointInformation();
                break;

            case 7:
                EnumeratePeopleNearMe();
                break;

            case 8:
                AddEndpointAsContact();
                break;

            case 9:
                ExportContact();
                break;

            case 10:
                ParseContact();
                break;
            
            case 11:
                ImportContact();
                break;
            
            case 12:
                DeleteContact();
                break;

            case 13:
                EnumContacts();
                break;
            
            case 14:
                SetWatching();
                break;

            case 15:
                SetWatchPermissions();
                break;

            case 16:
                GetPresenceInformation();
                break;
                    
            case 17:
                SetPresenceInformation();
                break;

            case 18:
                SubscribeEndpointData();
                break;

            case 19:
                UnsubscribeEndpointData();
                break;

            case 20:
                PublishEndpointObject();
                break;

            case 21:
                DeleteEndpointObject();
                break;
                                    
            case 22:
                RegisterApplication();
                break;

            case 23:
                UnregisterApplication();
                break;

            case 24:
                DisplayApplicationRegistrations();
                break;

            case 25:
                SendInvite();
                break;

            default:
                wprintf(L"Invalid selection.\n");
                break;

        }

        //Pause so that our output doesn't scroll
        //off the screen before the user gets a change to
        //read it.
         wprintf(L"\n\nPress <ENTER> to continue.\n");
        fflush(stdin);
        (void)StringCbGets(wzBuff, sizeof(wzBuff));
    }
}