Exemple #1
0
OsStatus OsConfigDb::loadFromFile(const char *filename)
{
   if (filename == NULL)
   {
       return OS_INVALID_ARGUMENT;
   }

   OsStatus retval = OS_UNSPECIFIED;
   OsWriteLock lock(mRWMutex);    // take lock for writing while the database
                                  //  is loaded

   setIdentityLabel(filename);

   OsConfigEncryption *encryption = getEncryption();
   if (encryption != NULL && encryption->isNormallyEncrypted(this))
   {
       retval = loadFromEncryptedFile(filename);
   }
   else
   {
       FILE *fp = fopen(filename,"rb");
       if (fp)
       {
           retval = loadFromUnencryptedFile(fp);
           fclose(fp);
       }
   }

   return retval;
}
Exemple #2
0
OsStatus OsConfigDb::storeToFile(const char *filename)
{
   if (filename == NULL)
   {
       return OS_INVALID_ARGUMENT;
   }

   OsStatus retval = OS_UNSPECIFIED;
   OsReadLock lock(mRWMutex);    // take lock for writing while the database
                                  //  is loaded

   setIdentityLabel(filename);
   OsConfigEncryption *encryption = getEncryption();
   if (encryption != NULL && encryption->isWriteEncryptedEnabled() &&
           encryption->isNormallyEncrypted(this))
   {
       retval = storeToEncryptedFile(filename);
   }
   else
   {
       FILE *fp = fopen(filename,"wb");
       if (!fp)
       {
           osPrintf("Could not open %s.  errno = %d\n",filename,errno);
           return retval;
       }
       retval = storeToFile(fp);

       fclose(fp);
   }

   return retval;
}
Exemple #3
0
//Security Key (Write Only)
bool setSecurityKey(char c[])			//SSID
{
	switch (getEncryption())
	{
		case 0:
		return false;
		case 1 || 2:
		{
			if(sizeof(c) >= 0 && sizeof(c) <= 31)	//ASCII
			break;
			else
			return false;
		}
		case 3:
		{
			if(sizeof(c) == 5 || sizeof(c) == 13)	//ASCII
			break;
			else
			return false;
		}
		default:
		return false;
	}
	
	if(ATEnable())
	{
		printf("ATPK%s\r", c);
		if(ok())
		return true;
		else
		return false;
	}
	else
	return false;
}
Exemple #4
0
OsStatus OsConfigDb::storeToEncryptedFile(const char *filename)
{
    OsStatus retval = OS_SUCCESS;

    // store to buffer
    size_t buffLen = calculateBufferSize();
    char *buff = new char[buffLen];
    storeToBuffer(buff);
    buffLen = strlen(buff);
    OsEncryption e;
    retval = getEncryption()->encrypt(this, &e, buff, buffLen);
    if (retval == OS_SUCCESS)
    {
        retval = storeBufferToFile(filename, (const char *)e.getResults(), e.getResultsLen());
    }

    return retval;
}
StringBuffer MailSyncSourceConfig::print() {

    StringBuffer ret;
    ret = "** SOURCE: "; ret += getName(); ret += "**\r\n";
    
    ret += "URI:\t\t"; ret += getURI(); ret += "\r\n";
    ret += "SyncModes:\t"; ret += getSyncModes(); ret += "\r\n";
    ret += "Type:\t\t"; ret += getType(); ret += "\r\n";
    ret += "Sync:\t\t"; ret += getSync(); ret += "\r\n";
    ret += "Encoding:\t"; ret += getEncoding(); ret += "\r\n";
    ret += "Version:\t"; ret += getVersion(); ret += "\r\n";
    ret += "SupportedType:\t"; ret += getSupportedTypes(); ret += "\r\n";
    ret += "Last:\t\t"; ret.append(getLast()); ret += "\r\n";
    ret += "Encryption:\t"; ret += getEncryption(); ret += "\r\n";    
    ret += "Enabled:\t"; ret += (isEnabled() == true ? "1" : "0"); ret += "\r\n";    


    ret += "DownloadAge:\t"; ret.append(getDownloadAge()); ret += "\r\n";    
    ret += "BodySize:\t"; ret.append(getBodySize()); ret += "\r\n";
    ret += "AttachSize:\t"; ret.append(getAttachSize()); ret += "\r\n";

    return ret;
}
Exemple #6
0
void WP3Parser::parse(librevenge::RVNGTextInterface *textInterface)
{
	librevenge::RVNGInputStream *input = getInput();
	WPXEncryption *encryption = getEncryption();
	std::list<WPXPageSpan> pageList;
	WPXTableList tableList;
	WP3ResourceFork *resourceFork = 0;
	std::vector<WP3SubDocument *> subDocuments;

	try
	{
		resourceFork = getResourceFork(input, encryption);

		// do a "first-pass" parse of the document
		// gather table border information, page properties (per-page)
		WP3StylesListener stylesListener(pageList, tableList, subDocuments);
		stylesListener.setResourceFork(resourceFork);
		parse(input, encryption, &stylesListener);

		// postprocess the pageList == remove duplicate page spans due to the page breaks
		std::list<WPXPageSpan>::iterator previousPage = pageList.begin();
		for (std::list<WPXPageSpan>::iterator Iter=pageList.begin(); Iter != pageList.end(); /* Iter++ */)
		{
			if ((Iter != previousPage) && (*previousPage==*Iter))
			{
				(*previousPage).setPageSpan((*previousPage).getPageSpan() + (*Iter).getPageSpan());
				Iter = pageList.erase(Iter);
			}
			else
			{
				previousPage = Iter;
				++Iter;
			}
		}

		// second pass: here is where we actually send the messages to the target app
		// that are necessary to emit the body of the target document
		WP3ContentListener listener(pageList, subDocuments, textInterface); // FIXME: SHOULD BE CONTENT_LISTENER, AND SHOULD BE PASSED TABLE DATA!
		listener.setResourceFork(resourceFork);
		parse(input, encryption, &listener);

		// cleanup section: free the used resources
		for (std::vector<WP3SubDocument *>::iterator iterSubDoc = subDocuments.begin(); iterSubDoc != subDocuments.end(); ++iterSubDoc)
		{
			if (*iterSubDoc)
				delete *iterSubDoc;
		}

		delete resourceFork;
	}
	catch (FileException)
	{
		WPD_DEBUG_MSG(("WordPerfect: File Exception. Parse terminated prematurely."));

		for (std::vector<WP3SubDocument *>::iterator iterSubDoc = subDocuments.begin(); iterSubDoc != subDocuments.end(); ++iterSubDoc)
		{
			if (*iterSubDoc)
				delete *iterSubDoc;
		}

		delete resourceFork;

		throw FileException();
	}
}
rspfRefPtr<rspfProperty> rspfNitfFileHeaderV2_X::getProperty(const rspfString& name)const
{
   rspfRefPtr<rspfProperty> property = 0;
   
   if(name == FHDR_KW)
   {
      property = new rspfStringProperty(name, rspfString(theFileTypeVersion));
   }
   else if(name == VERSION_KW)
   {
      property = new rspfStringProperty(name, rspfString(getVersion()));
   }
   else if(name == FILE_TYPE_KW)
   {
      property = new rspfStringProperty(name, "NITF");
   }
   else if(name == CLEVEL_KW)
   {
      rspfNumericProperty* numericProperty =
         new rspfNumericProperty(name,
                                  getComplexityLevel(),
                                  1,
                                  99);
      numericProperty->setNumericType(rspfNumericProperty::rspfNumericPropertyType_INT);
      property = numericProperty;
      
   }
   else if(name == STYPE_KW)
   {
      property = new rspfStringProperty(name, getSystemType().trim());
   }
   else if(name == OSTAID_KW)
   {
      property = new rspfStringProperty(name, getOriginatingStationId().trim());
   }
   else if(name == FDT_KW)
   {
      property = new rspfStringProperty(name, getDate());
   }
   else if(name == FTITLE_KW)
   {
      property = new rspfStringProperty(name, getTitle().trim());
   }
   else if(name == FSCLAS_KW)
   {
      rspfStringProperty* stringProperty =
         new rspfStringProperty(name,
                                 getSecurityClassification().trim(),
                                 false);
      
      stringProperty->addConstraint("");
      stringProperty->addConstraint("T");
      stringProperty->addConstraint("S");
      stringProperty->addConstraint("C");
      stringProperty->addConstraint("R");
      stringProperty->addConstraint("U");
      
      property = stringProperty;
   }
   else if(name == FSCODE_KW)
   {
      property = new rspfStringProperty(name,
                                         getCodeWords().trim());
   }
   else if(name == FSCTLH_KW)
   {
      property = new rspfStringProperty(name,
                                         getControlAndHandling().trim());
   }
   else if(name == FSREL_KW)
   {
      property = new rspfStringProperty(name,
                                         getReleasingInstructions().trim());
   }
   else if(name == FSCAUT_KW)
   {
      property = new rspfStringProperty(name,
                                         getClassificationAuthority().trim());
   }
   else if(name == FSCTLN_KW)
   {
      property = new rspfStringProperty(name,
                                         getSecurityControlNumber().trim());
      
   }
   else if(name == FSCOP_KW)
   {
      property = new rspfStringProperty(name,
                                         getCopyNumber().trim());
   }
   else if(name == FSCPYS_KW)
   {
      property = new rspfStringProperty(name,
                                         getNumberOfCopies().trim());
   }
   else if(name == ENCRYP_KW)
   {
      property = new rspfStringProperty(name,
                                         getEncryption().trim(),
                                         false);
   }
   else
   {
      property = rspfNitfFileHeader::getProperty(name).get();
   }
   
   return property;
}