Exemplo n.º 1
0
INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
{
	if (IsOnline())
	{
		CSkypeGCCreateDlg dlg(this);
		if (!dlg.DoModal())
		{
			return 1;
		}
		LIST<char>uids(1);
		for (std::vector<MCONTACT>::size_type i = 0; i < dlg.m_hContacts.size(); i++)
		{
			uids.insert(db_get_sa(dlg.m_hContacts[i], m_szModuleName, SKYPE_SETTINGS_ID));
		}
		uids.insert(getStringA(SKYPE_SETTINGS_ID));

		SendRequest(new CreateChatroomRequest(m_szRegToken, uids, ptrA(getStringA(SKYPE_SETTINGS_ID)), m_szServer));

		for (int i = 0; i < uids.getCount(); i++)
			mir_free(uids[i]);
		uids.destroy();
		return 0;
	}
	return 1;
}
Exemplo n.º 2
0
static void DumpText(bool doHTML, const BlockMultipleAlignment *alignment,
    const vector < int >& rowOrder,
    BlockMultipleAlignment::eUnalignedJustification justification, CNcbiOstream& os)
{

#define LEFT_JUSTIFY resetiosflags(IOS_BASE::right) << setiosflags(IOS_BASE::left)
#define RIGHT_JUSTIFY resetiosflags(IOS_BASE::left) << setiosflags(IOS_BASE::right)

    // do whole alignment for now
    unsigned int firstCol = 0, lastCol = alignment->AlignmentWidth() - 1, nColumns = 60;

    if (lastCol >= alignment->AlignmentWidth() || firstCol > lastCol || nColumns < 1) {
        ERRORMSG("DumpText() - nonsensical display region parameters");
        return;
    }

    // HTML colors
    static const string
        bgColor("#FFFFFF"), rulerColor("#700777"), numColor("#229922");

    // set up the titles and uids, figure out how much space any seqLoc string will take
    vector < string > titles(alignment->NRows()), uids(doHTML ? alignment->NRows() : 0);
    unsigned int alnRow, row, maxTitleLength = 0, maxSeqLocStrLength = 0, leftMargin, decimalLength;
    for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) {
        row = rowOrder[alnRow]; // translate display row -> data row
        const Sequence *sequence = alignment->GetSequenceOfRow(row);

        titles[row] = sequence->identifier->ToString();
        if (titles[row].size() > maxTitleLength) maxTitleLength = titles[row].size();
        decimalLength = ((int) log10((double) sequence->Length())) + 1;
        if (decimalLength > maxSeqLocStrLength) maxSeqLocStrLength = decimalLength;

        // uid for link to entrez
        if (doHTML) {
            // prefer gi's, since accessions can be outdated
            if (sequence->identifier->gi != MoleculeIdentifier::VALUE_NOT_SET) {
                uids[row] = NStr::IntToString(sequence->identifier->gi);
            } else if (sequence->identifier->pdbID.size() > 0) {
                if (sequence->identifier->pdbID != "query" &&
                    sequence->identifier->pdbID != "consensus") {
                    uids[row] = sequence->identifier->pdbID;
                    if (sequence->identifier->pdbChain != ' ')
                        uids[row] += string("_")  + (char) sequence->identifier->pdbChain;
                }
            } else {
                uids[row] = sequence->identifier->GetLabel();
            }
        }
    }
    leftMargin = maxTitleLength + maxSeqLocStrLength + 2;

    // need to keep track of first, last seqLocs for each row in each paragraph;
    // find seqLoc of first residue >= firstCol
    vector < int > lastShownSeqLocs(alignment->NRows());
    unsigned int alnLoc, i;
    char ch;
    Vector color, bgCol;
    bool highlighted, drawBG;
    for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) {
        row = rowOrder[alnRow]; // translate display row -> data row
        lastShownSeqLocs[row] = -1;
        for (alnLoc=0; alnLoc<firstCol; ++alnLoc) {
            if (!alignment->GetCharacterTraitsAt(alnLoc, row, justification,
                    &ch, &color, &highlighted, &drawBG, &bgCol))
                ch = '~';
            if (ch != '~') lastShownSeqLocs[row]++;
        }
    }

    // header
    if (doHTML)
        os << "<HTML><TITLE>Alignment Exported From Cn3D</TITLE>\n" <<
            "<BODY BGCOLOR=" << bgColor << ">\n";

    // split alignment up into "paragraphs", each with nColumns
    if (doHTML) os << "<TABLE>\n";
    int paragraphStart, nParags = 0;
    for (paragraphStart=0; (firstCol+paragraphStart)<=lastCol; paragraphStart+=nColumns, ++nParags) {

        // start table row
        if (doHTML)
            os << "<tr><td><pre>\n";
        else
            if (paragraphStart > 0) os << '\n';

        // do ruler
        unsigned int nMarkers = 0, width;
        if (doHTML) os << "<font color=" << rulerColor << '>';
        for (i=0; i<nColumns && (firstCol+paragraphStart+i)<=lastCol; ++i) {
            if ((paragraphStart+i+1)%10 == 0) {
                if (nMarkers == 0)
                    width = leftMargin + i + 1;
                else
                    width = 10;
                os << RIGHT_JUSTIFY << setw(width) << (paragraphStart+i+1);
                ++nMarkers;
            }
        }
        if (doHTML) os << "</font>";
        os << '\n';
        if (doHTML) os << "<font color=" << rulerColor << '>';
        for (i=0; i<leftMargin; ++i) os << ' ';
        for (i=0; i<nColumns && (firstCol+paragraphStart+i)<=lastCol; ++i) {
            if ((paragraphStart+i+1)%10 == 0)
                os << '|';
            else if ((paragraphStart+i+1)%5 == 0)
                os << '*';
            else
                os << '.';
        }
        if (doHTML) os << "</font>";
        os << '\n';

        int nDisplayedResidues;

        // output each alignment row
        for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) {
            row = rowOrder[alnRow]; // translate display row -> data row
            const Sequence *sequence = alignment->GetSequenceOfRow(row);

            // actual sequence characters and colors; count how many non-gaps in each row
            nDisplayedResidues = 0;
            string rowChars;
            vector < string > rowColors;
            for (i=0; i<nColumns && (firstCol+paragraphStart+i)<=lastCol; ++i) {
                if (!alignment->GetCharacterTraitsAt(firstCol+paragraphStart+i, row, justification,
                        &ch, &color, &highlighted, &drawBG, &bgCol))
                    ch = '?';
                rowChars += ch;
                wxString colorStr;
                colorStr.Printf("#%02x%02x%02x",
                    (int) (color[0]*255), (int) (color[1]*255), (int) (color[2]*255));
                rowColors.push_back(WX_TO_STD(colorStr));
                if (ch != '~') ++nDisplayedResidues;
            }

            // title
            if (doHTML && uids[row].size() > 0) {
				string descr = sequence->GetDescription();
                os << "<a href=\"http://www.ncbi.nlm.nih.gov/protein/"
                    << uids[row] << "\" onMouseOut=\"window.status=''\"\n"
                    << "onMouseOver=\"window.status='"
                    << ShortAndEscapedString((descr.size() > 0) ? descr : titles[row])
                    << "';return true\">"
                    << setw(0) << titles[row] << "</a>";
            } else {
                os << setw(0) << titles[row];
            }
            os << setw(maxTitleLength+1-titles[row].size()) << ' ';

            // left start pos (output 1-numbered for humans...)
            if (doHTML) os << "<font color=" << numColor << '>';
            if (nDisplayedResidues > 0)
                os << RIGHT_JUSTIFY << setw(maxSeqLocStrLength) << (lastShownSeqLocs[row]+2) << ' ';
            else
                os << RIGHT_JUSTIFY << setw(maxSeqLocStrLength) << ' ' << ' ';

            // dump sequence, applying color changes only when necessary
            if (doHTML) {
                string prevColor;
                for (i=0; i<rowChars.size(); ++i) {
                    if (rowColors[i] != prevColor) {
                        os << "</font><font color=" << rowColors[i] << '>';
                        prevColor = rowColors[i];
                    }
                    os << rowChars[i];
                }
                os << "</font>";
            } else
                os << rowChars;

            // right end pos
            if (nDisplayedResidues > 0) {
                os << ' ';
                if (doHTML) os << "<font color=" << numColor << '>';
                os << LEFT_JUSTIFY << setw(0) << (lastShownSeqLocs[row]+nDisplayedResidues+1);
                if (doHTML) os << "</font>";
            }
            os << '\n';

            // setup to begin next parag
            lastShownSeqLocs[row] += nDisplayedResidues;
        }

        // end table row
        if (doHTML) os << "</pre></td></tr>\n";
    }

    if (doHTML)
        os << "</TABLE>\n"
            << "</BODY></HTML>\n";

    // additional sanity check on seqloc markers
    if (firstCol == 0 && lastCol == alignment->AlignmentWidth()-1) {
        for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) {
            row = rowOrder[alnRow]; // translate display row -> data row
            if (lastShownSeqLocs[row] != (int)alignment->GetSequenceOfRow(row)->Length() - 1) {
                ERRORMSG("DumpText: full display - seqloc markers don't add up for row " << row);
                break;
            }
        }
        if (alnRow != alignment->NRows())
            ERRORMSG("DumpText: full display - seqloc markers don't add up correctly");
    }
}