smf/smfservermodule/smfclient/common/smfurl.cpp
changeset 14 a469c0e6e7fb
equal deleted inserted replaced
13:b5d63d5fc252 14:a469c0e6e7fb
       
     1 /**
       
     2  * Copyright (c) 2010 Sasken Communication Technologies Ltd.
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the "Eclipse Public License v1.0" 
       
     6  * which accompanies  this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
       
    11  *
       
    12  * Contributors:
       
    13  * Manasij Roy, Nalina Hariharan
       
    14  * 
       
    15  * Description:
       
    16  * The SmfUrl class represents an URL. This class has been constructed based on 
       
    17  * the link element of the The Atom Syndication Format 
       
    18  * (refer http://tools.ietf.org/html/rfc4287)
       
    19  * For detailed description about atom link relations, refer 
       
    20  * "http://www.iana.org/assignments/link-relations/link-relations.xhtml"
       
    21  *
       
    22  */
       
    23 
       
    24 #include <QUrl>
       
    25 
       
    26 #include "smfurl.h"
       
    27 #include "smfurl_p.h"
       
    28 
       
    29 /**
       
    30  * Constructor with default argument
       
    31  */
       
    32 SmfUrl::SmfUrl( )
       
    33 	{
       
    34 	d = new SmfUrlPrivate;
       
    35 	}
       
    36 
       
    37 /**
       
    38  * Copy Constructor
       
    39  * @param aOther The reference object
       
    40  */
       
    41 SmfUrl::SmfUrl( const SmfUrl &aOther )
       
    42 	: d( aOther.d )
       
    43 	{
       
    44 	}
       
    45 
       
    46 /**
       
    47  * Overloaded = operator
       
    48  * @param aOther The reference object
       
    49  * @return The target reference value
       
    50  */
       
    51 SmfUrl& SmfUrl::operator=( const SmfUrl &aOther )
       
    52 	{
       
    53 	d->m_id = aOther.d->m_id;
       
    54 	return *this;
       
    55 	}
       
    56 
       
    57 /**
       
    58  * Destructor
       
    59  */
       
    60 SmfUrl::~SmfUrl( )
       
    61 	{
       
    62 	}
       
    63 
       
    64 
       
    65 /**
       
    66  * Method to get the href attribute of the link
       
    67  * @return The href attribute of the link
       
    68  */
       
    69 QUrl SmfUrl::href( ) const
       
    70 	{
       
    71 	return d->m_href;
       
    72 	}
       
    73 
       
    74 /**
       
    75  * Method to get the rel attribute of the link
       
    76  * @return The rel attribute of the link
       
    77  */
       
    78 QString SmfUrl::rel( ) const
       
    79 	{
       
    80 	return d->m_rel;
       
    81 	}
       
    82 
       
    83 /**
       
    84  * Method to get the type attribute of the link
       
    85  * @return The type attribute of the link
       
    86  */
       
    87 QString SmfUrl::type( ) const
       
    88 	{
       
    89 	return d->m_type;
       
    90 	}
       
    91 
       
    92 /**
       
    93  * Method to get the hreflang attribute of the link
       
    94  * @return The hreflang attribute of the link
       
    95  */
       
    96 QString SmfUrl::hreflang( ) const
       
    97 	{
       
    98 	return d->m_hreflang;
       
    99 	}
       
   100 
       
   101 /**
       
   102  * Method to get the title attribute of the link
       
   103  * @return The title attribute of the link
       
   104  */
       
   105 QString SmfUrl::title( ) const
       
   106 	{
       
   107 	return d->m_title;
       
   108 	}
       
   109 
       
   110 /**
       
   111  * Method to get the length attribute of the link
       
   112  * @return The length attribute of the link
       
   113  */
       
   114 QString SmfUrl::length( ) const
       
   115 	{
       
   116 	return d->m_length;
       
   117 	}
       
   118 
       
   119 /**
       
   120  * Method to get the id of the URL
       
   121  * @return The ID of the URL
       
   122  */
       
   123 QString SmfUrl::id( ) const
       
   124 	{
       
   125 	return d->m_id;
       
   126 	}
       
   127 
       
   128 /**
       
   129  * Method to set the href attribute of the link
       
   130  * @param aData The href attribute of the link
       
   131  */
       
   132 void SmfUrl::setHref( const QUrl& aData )
       
   133 	{
       
   134 	d->m_href = aData;
       
   135 	}
       
   136 
       
   137 /**
       
   138  * Method to set the rel attribute of the link
       
   139  * @param aData The rel attribute of the link
       
   140  */
       
   141 void SmfUrl::setRel( const QString &aData )
       
   142 	{
       
   143 	d->m_rel = aData;
       
   144 	}
       
   145 
       
   146 /**
       
   147  * Method to set the type attribute of the link
       
   148  * @param aData The type attribute of the link
       
   149  */
       
   150 void SmfUrl::setType( const QString &aData )
       
   151 	{
       
   152 	d->m_type = aData;
       
   153 	}
       
   154 
       
   155 /**
       
   156  * Method to set the hreflang attribute of the link
       
   157  * @param aData The hreflang attribute of the link
       
   158  */
       
   159 void SmfUrl::setHhreflang( const QString &aData )
       
   160 	{
       
   161 	d->m_hreflang = aData;
       
   162 	}
       
   163 
       
   164 /**
       
   165  * Method to set the title attribute of the link
       
   166  * @param aData The title attribute of the link
       
   167  */
       
   168 void SmfUrl::setTitle( const QString &aData )
       
   169 	{
       
   170 	d->m_title = aData;
       
   171 	}
       
   172 
       
   173 /**
       
   174  * Method to set the length attribute of the link
       
   175  * @param aData The length attribute of the link
       
   176  */
       
   177 void SmfUrl::setLength( const QString &aData )
       
   178 	{
       
   179 	d->m_length = aData;
       
   180 	}
       
   181 
       
   182 /**
       
   183  * Method to set the id of the URL
       
   184  * @param aId The ID of the URL
       
   185  */
       
   186 void SmfUrl::setId( const QString &aId )
       
   187 	{
       
   188 	d->m_id = aId;
       
   189 	}
       
   190 
       
   191 
       
   192 /**
       
   193  * Method for Externalization. Writes the SmfUrl object to 
       
   194  * the stream and returns a reference to the stream.
       
   195  * @param aDataStream Stream to be written
       
   196  * @param aUrl The SmfUrl object to be externalized
       
   197  * @return reference to the written stream
       
   198  */
       
   199  QDataStream &operator<<( QDataStream &aDataStream, 
       
   200 		const SmfUrl &aUrl )
       
   201 	{
       
   202 	// Serialize d->m_href
       
   203 	aDataStream<<aUrl.d->m_href;
       
   204 	
       
   205 	// Serialize d->m_rel
       
   206 	aDataStream<<aUrl.d->m_rel;
       
   207 	
       
   208 	// Serialize d->m_type
       
   209 	aDataStream<<aUrl.d->m_type;
       
   210 	
       
   211 	// Serialize d->m_hreflang
       
   212 	aDataStream<<aUrl.d->m_hreflang;
       
   213 	
       
   214 	// Serialize d->m_title
       
   215 	aDataStream<<aUrl.d->m_title;
       
   216 	
       
   217 	// Serialize d->m_length
       
   218 	aDataStream<<aUrl.d->m_length;
       
   219 	
       
   220 	// Serialize d->m_id
       
   221 	aDataStream<<aUrl.d->m_id;
       
   222 	
       
   223 	return aDataStream;
       
   224 	}
       
   225 
       
   226 /**
       
   227  * Method for Internalization. Reads a SmfUrl object from 
       
   228  * the stream and returns a reference to the stream.
       
   229  * @param aDataStream Stream to be read
       
   230  * @param aUrl The SmfUrl object to be internalized
       
   231  * @return reference to the stream
       
   232  */
       
   233 QDataStream &operator>>( QDataStream &aDataStream, 
       
   234 		SmfUrl &aUrl)
       
   235 	{
       
   236 	// Deserialize d->m_href
       
   237 	aDataStream>>aUrl.d->m_href;
       
   238 	
       
   239 	// Deserialize d->m_rel
       
   240 	aDataStream>>aUrl.d->m_rel;
       
   241 	
       
   242 	// Deserialize d->m_type
       
   243 	aDataStream>>aUrl.d->m_type;
       
   244 	
       
   245 	// Deserialize d->m_hreflang
       
   246 	aDataStream>>aUrl.d->m_hreflang;
       
   247 	
       
   248 	// Deserialize d->m_title
       
   249 	aDataStream>>aUrl.d->m_title;
       
   250 	
       
   251 	// Deserialize d->m_length
       
   252 	aDataStream>>aUrl.d->m_length;
       
   253 	
       
   254 	// Deserialize d->m_id
       
   255 	aDataStream>>aUrl.d->m_id;
       
   256 	
       
   257 	return aDataStream;
       
   258 	}
       
   259