GSM_Error GSM_Phone_N7110::GetSMSFolders(GSM_SMSMMSFolders *Folders)
{
	unsigned char Buff[] = {NOKIA_FRAME1, 0x7A, 0x00, 0x00};

	(*Debug)->Deb("SENT: getting SMS folders\n");
	return Write(Buff, sizeof(Buff), 0x14, 4, ID_GetSMSFolders+ID, Folders);
}

GSM_Error GSM_Phone_N7110::GetNextSMS(GSM_SMSList *List, BOOLEAN start, int *Folder, int *Current, int *MaxInFolder)
{
	GSM_Error	       error;
	unsigned int	    i;
	bool		    findnextfolder = TRUE;
	GSM_SMSMMSFolders	       Folders;
	GSM_SMSMMSFoldersSubEntry  *SubEntry;
	wchart		  SMSID;

	if (start == TRUE) {
		SMSFolderID     = 0x00;
		SMSFoldersNum   = 0;
		SubEntry	= NULL;
		error = GetSMSFolders(&Folders);
		if (error.Code!=GSM_ERR_NONE) return error;
		while (Folders.GetNext(&SubEntry) == TRUE) SMSFoldersNum++;
	} else {
		for (i=0;i<SMSLocations.Locations.size();i++) {
			if (SMSLocations.Locations.data()[i]==SMSLocation) break;
		}
		if (i<SMSLocations.Locations.size()-1) {
			SMSLocation=SMSLocations.Locations.data()[i+1];
			*Current = i+2;
			findnextfolder=FALSE;
		}
	}
	if (findnextfolder==TRUE) {
		SMSLocations.Locations.clear();
		while (SMSLocations.Locations.size()==0) {
			SMSFolderID+=0x08;

			/* Too high folder number */
			if ((SMSFolderID/0x08)>SMSFoldersNum) {
				return GSM_Return_Error(GSM_ERR_EMPTY);
			}

			/* Get next folder status */
			SMSLocations.FolderID = SMSFolderID;
			error = GetSMSFolderStatus(&SMSLocations);
			if (error.Code != GSM_ERR_NONE) return error;

			/* First location from this folder */
			SMSLocation=SMSLocations.Locations.data()[0];
			*Current = 1;
		}
	}
	SetSMSLocation(&SMSID, SMSFolderID, SMSLocation);

	*Folder	 = SMSFolderID;
	*MaxInFolder    = SMSLocations.Locations.length();
	return GetSMS(List,SMSID);
}
