示例#1
0
void Url::dump()
{
    UtlString proto;
    getUrlType(proto);
    printf("Url type: '%s'\n", proto.data());

    UtlString disp;
    getDisplayName(disp);
    printf("DisplayName: '%s'\n", disp.data());

    UtlString user;
    getUserId(user);
    printf("UserId: '%s'\n", user.data());

    UtlString pwd;
    getPassword(pwd);
    printf("Password: '******'\n", pwd.data());

    UtlString server;
    getHostAddress(server);
    printf("Address: '%s'\n", server.data());

    int port = getHostPort();
    printf("Port: %d\n", port);

    UtlString callId;
    getHeaderParameter("call-id", callId);
    printf("Call-Id: '%s'\n", callId.data());

    UtlString name;
    UtlString value;
    int index = 0;
    printf("\nHeader Parameters:\n");
    while(getHeaderParameter(index, name, value))
    {
        printf("'%s'='%s'\n", name.data(), value.data());
        index++;
    }

    index = 0;
    printf("\nField Parameters:\n");
    while(getFieldParameter(index, name, value))
    {
        printf("'%s'='%s'\n", name.data(), value.data());
        index++;
    }

    index = 0;
    printf("\nURL Parameters:\n");
    while(getUrlParameter(index, name, value))
    {
        printf("'%s'='%s'\n", name.data(), value.data());
        index++;
    }
}
示例#2
0
void Parser3::ParseUrl( QUrl U )
{
    if( !U.isValid() )
        return;
    BasePtr Info;

    Parser3_Sender *S=0;


    QString Url;

    QString ID = extractID( U );
    UrlType Type = getUrlType( U );

    switch( Type ) {
    case( UT_Video ):
    case( UT_Video_Feed ):
        Url = "http://gdata.youtube.com/feeds/api/videos/"+ID+"?v=2";
        Info = new VideoInfo;
        S = new Parser3_Sender(this, Info );
        connect( S, SIGNAL(Signal(BasePtr,QDomDocument)), SLOT(VideoRecived(BasePtr,QDomDocument)) );
        break;
    case( UT_Playlist ):
    case( UT_Playlist_Feed ):
        Url = "http://gdata.youtube.com/feeds/api/playlists/"+ID+"?v=2&start-index=1&max-results=50";
        Info = new VideoFeed;
        Info->cast_VideoFeed()->Type = VideoFeed::FT_Playlist;
        S = new Parser3_Sender( this, Info );
        connect( S, SIGNAL(Signal(BasePtr,QDomDocument)), SLOT(PlaylistRecived(BasePtr,QDomDocument)) );
        break;
    case( UT_User ):
    case( UT_User_Feed ):
        Url = "http://gdata.youtube.com/feeds/api/users/"+ID+"?v=2";
        Info = new UserInfo;
        S = new Parser3_Sender( this, Info );
        connect( S, SIGNAL(Signal(BasePtr,QDomDocument)), SLOT(UserRecived(BasePtr,QDomDocument)) );
        break;
    default:
        Error( QString("Unown url type! Url[%1]").arg(Url) );
    }

    mQue.push_back( qMakePair( QNetworkRequest(QUrl(Url)),QPointer<Parser3_Sender>(S)) );

}
示例#3
0
QString Parser3::extractID( QUrl U ) {
    ///@ todo add suport for feeds

    QString Url = U.toString();

    UrlType Type = getUrlType( U );

    QStringList Elements = Url.split('/', QString::SkipEmptyParts);

    QString ID = "";
    switch( Type ) {
    case( UT_Video ):
        ID = Elements.at(2).mid(8,11);
        break;
    case( UT_Playlist ):
        ID = Elements.at(2).mid(16,17);
        break;
    case( UT_User ):
        ID = Elements.at(3);
        break;
    default:
        Error( QString("Unown url! cant extract ID! Url[1%]").arg(Url) );
        break;
    }

    /// Characters to remove from id,
    /// example USER#p will be USER
    static const char RemoveCharacter[] = { '#', '?', '=', '&' };
    int temp = 0;
    for( int i=0; i < sizeof(RemoveCharacter); i++, temp=0 ){
        temp = ID.indexOf(RemoveCharacter[i]);
        if( temp != -1 )// found?
            ID.remove(temp,ID.size()-temp);
    }
    return ID;
}