Exemplo n.º 1
0
void Strings::setText(const char* value)
{
	AutoUpdater autoUpdater(*this);

	std::string valueStr(value);
	std::string lineBreak = getLineBreak();
	int start = 0;

	clear();
	while (true)
	{
		std::string::size_type pos = valueStr.find(lineBreak, start);
		if (pos != std::string::npos)
		{
			add(valueStr.substr(start, pos - start).c_str());
			start = (int)(pos + lineBreak.length());
		}
		else
		{
			std::string str = valueStr.substr(start);
			if (!str.empty())
				add(str.c_str());
			break;
		}
	}
}
Exemplo n.º 2
0
	Rect Font::calculateRectOfIndex(int index, const char *str, const Rect& bound) const {
		int line = calculateLine(index, str, bound);
		int lineBreak = 0;
		if(line>0) 
			lineBreak = getLineBreak(line-1, str, bound);
	
		MAPoint2d cursor = {0, 0};
		cursor.y+=line*mCharset->lineHeight;
		MAExtent lineRect = getStringDimensions(&str[lineBreak], index-lineBreak);
		cursor.x+=EXTENT_X(lineRect);
		MAExtent charRect = getStringDimensions(&str[index], 1);
		return Rect(cursor.x, cursor.y, EXTENT_X(charRect), mCharset->lineHeight);

	}
Exemplo n.º 3
0
std::string Strings::getText() const
{
	std::string result;
	int count = getCount();
	std::string lineBreak = getLineBreak();

	for (int i = 0; i < count; i++)
	{
		result += getString(i);
		result += lineBreak;
	}

	return result;
}
Exemplo n.º 4
0
KWBoolean
SMTPGetLine(SMTPClient *client)
{
   static const char mName[] = "SMTPGetLine";
   char *lineBreak;
   size_t lineLength;
   KWBoolean bResult = KWTrue;

/*--------------------------------------------------------------------*/
/*                   Handle previously signaled EOF                   */
/*--------------------------------------------------------------------*/

   if (isClientEOF(client) && (client->receive.NetworkUsed == 0))
   {
      printmsg(0, "%s: client %d is out of data (EOF)",
                   mName,
                   getClientSequence(client));

      SetDataLine(client, "", 0);
      setClientMode(client, SM_ABORT);
      return KWTrue;
   }

/*--------------------------------------------------------------------*/
/*       Read more data if we have some and need it,                  */
/*--------------------------------------------------------------------*/

   lineBreak = getLineBreak(&client->receive);

   if (getClientReady(client) && (lineBreak == NULL))
   {
      if (client->stalledReads)     /* Improve response time ...     */
         client->stalledReads--;

      SMTPRead(client);
      lineBreak = getLineBreak(&client->receive);
   }

/*--------------------------------------------------------------------*/
/*              If no data available, return immediately              */
/*--------------------------------------------------------------------*/

   if (lineBreak == NULL)
   {

      if (isClientEOF(client))
      {
         static const char quit[] = "quit";
         static const size_t quitLength = sizeof quit - 1;

         if ((client->receive.NetworkUsed == quitLength) &&
             equalni(client->receive.NetworkBuffer, quit, quitLength))
         {
            printmsg(8,"%s: Applying CR/LF after Netscape %s/EOF",
                     mName,
                     quit);
            SetDataLine(client, client->receive.NetworkBuffer, quitLength);
            SMTPBurpBuffer(client, client->receive.NetworkUsed);
         }
         else {
            printmsg(0, "%s: Client %d Terminated unexpectedly without QUIT",
                       mName,
                       getClientSequence(client));
            SMTPBurpBuffer(client, client->receive.NetworkUsed);

            /* Abort client immediately */
            setClientMode(client, SM_ABORT);
            return KWTrue;
         }
      }
      else if (client->receive.NetworkUsed < MAX_BUFFER_SIZE)
      {
         printmsg(2, "%s: Client %d Input buffer "
                      "(%d bytes) waiting for data.",
                      mName,
                      getClientSequence(client),
                      client->receive.NetworkUsed);

         /* Sleep client for few secs  */
         setClientIgnore(client, (time_t) ++client->stalledReads);

         /* Don't process command yet  */
         return KWFalse;

      } /* END if (client->receive.NetworkUsed < MAX_BUFFER_SIZE) */
      else {

        printmsg(0, "%d <<< %.125s",
                     getClientSequence(client),
                     client->receive.NetworkBuffer);
        printmsg(0, "%s: Client %d Input buffer (%d bytes) full (cannot append more).",
                     mName,
                     getClientSequence(client),
                     client->receive.NetworkUsed);

        SetDataLine(client,
                    client->receive.NetworkBuffer,
                    client->receive.NetworkUsed);
        SMTPBurpBuffer(client, client->receive.NetworkUsed);

        /* Abort client immediately     */
        setClientMode(client, SM_ABORT);
        return KWTrue;

      } /* END else */

   } /* END if (lineBreak == NULL) */

   lineLength = lineBreak - client->receive.NetworkBuffer;
   bResult = SetDataLine(client,
                         client->receive.NetworkBuffer,
                         lineLength);

   SMTPBurpBuffer(client, lineLength + 2);
   return bResult;

} /* END SMTPGetLine */