text:
/
    printf("                               22: 32bppBGRA" CRLF);
    printf("                               23: 64bppRGBA" CRLF);
    printf("                               24: 64bppRGBAFixedPoint" CRLF);
    printf("                               25: 64bppRGBAHalf" CRLF);
//    printf("                               26 - 128bpp RGBA" CRLF);
    printf("                               27: 128bppRGBAFixedPoint" CRLF);
    printf("                               28: 128bppRGBAFloat" CRLF);

    printf("                               29: 16bppBGR555" CRLF);
    printf("                               30: 16bppBGR565" CRLF);
    printf("                               31: 32bppBGR101010" CRLF);
    //printf("                               101..116 - 1..16 channel 8bpp" CRLF);
    printf("                               32: 40bppCMYKA" CRLF);
    printf("                               33: 80bppCMYKA" CRLF);

    printf("                               34: 32bppBGR" CRLF);
/*
    printf("                               35:  32bppPBGRA" CRLF);
    printf("                               36:  64bppPRGBA" CRLF);
    printf("                               37: 128bppPRGBA Float" CRLF);
*/
    printf(CRLF);

    printf("  -r top left height width     Specifies the rectangle for region decode" CRLF);
    printf(CRLF);
    printf("  -T m                         Reduced resolution (mipmap) decode" CRLF);
    printf("                                0: Full resolution (default)" CRLF);
    printf("                                1: 1/2 res (down-sampled from full res)" CRLF);
    printf("                                2: 1/4 res (native decode)" CRLF);
    printf("                                3: 1/8 res (down-sampled from 1/4 res)" CRLF);
    printf("                                4: 1/16 res (native decode)" CRLF);
    printf("                               >4: 1/(2^m) res (down-sampled from 1/16 res) " CRLF);
    printf(CRLF);

    printf("  -O orientation               0: No transformation (default)" CRLF);
    printf("                               1: Flip vertically" CRLF);
    printf("                               2: Flip horizontally" CRLF);
    printf("                               3: Flip vertically & horizontally" CRLF);
    printf("                               4: Rotate 90 degrees CW" CRLF);
    printf("                               5: Rotate 90 degrees CW & flip vertically" CRLF);
    printf("                               6: Rotate 90 degrees CW & flip horizontally" CRLF);
    printf("                               7: Rotate 90 degrees CW & flip vert & horiz" CRLF);
    printf(CRLF);

    printf("  -s skip subbands             Used for compressed domain transcoding" CRLF);
    printf("                               0: All subbands included (default)" CRLF);
    printf("                               1: Skip flexbits" CRLF);
    printf("                               2: Skip highpass" CRLF);
    printf("                               3: Skip highpass & lowpass (DC only)" CRLF);
    printf(CRLF);

    printf("  -a alpha decode              0: Decode without alpha channel" CRLF);
    printf("                               1: Decode only alpha channel" CRLF);
    printf("                               2: Decode image & alpha (default)" CRLF);
    printf(CRLF);

    printf("  -p strength                  Post processing filter strength" CRLF);
    printf("                               0: None (default)" CRLF);
    printf("                               1: Light" CRLF);
    printf("                               2: Medium" CRLF);
    printf("                               3: Strong" CRLF);
    printf("                               4: Very strong" CRLF);
    printf(CRLF);

    printf("  -C                           Suppress overlapping boundary macro blocks" CRLF);
    printf("                               (Used for compressed domain tile extraction)" CRLF);
    printf(CRLF);

    printf("  -t                           Display timing information" CRLF);
    printf(CRLF);

    printf("  -v                           Display verbose decoder information" CRLF);
    printf(CRLF);
    printf("Eg: %s -i input.jxr -o output.bmp -c 0" CRLF, szExe);
}

void WmpDecAppShowArgs(WMPDECAPPARGS* args)
{
	GUID guidPF = args->guidPixFormat;

    printf("================================" CRLF);
    printf("Input file:     %s" CRLF, args->szInputFile);
    printf("Output file:    %s" CRLF, args->szOutputFile);
    printf("Color format:   %08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X" CRLF,
        guidPF.Data1, guidPF.Data2, guidPF.Data3, guidPF.Data4[0], guidPF.Data4[1], guidPF.Data4[2],
        guidPF.Data4[3], guidPF.Data4[4], guidPF.Data4[5], guidPF.Data4[6], guidPF.Data4[7]);
    printf("Post processing strength: %d" CRLF, args->cPostProcStrength);
    printf("Thumbnail:      %d" CRLF, (int) args->tThumbnailFactor);
    printf("================================" CRLF);
}

//----------------------------------------------------------------
void WmpDecAppInitDefaultArgs(WMPDECAPPARGS* args)
{
    memset(args, 0, sizeof(*args));
    args->guidPixFormat = GUID_PKPixelFormatDontCare;
//    args->bFlagRGB_BGR = FALSE; //default BGR
    args->bVerbose = FALSE;
    args->tThumbnailFactor = 0;
    args->oOrientation = O_NONE;
    args->cPostProcStrength = 0;
    args->uAlphaMode = 255;
    args->sbSubband = SB_ALL;
}

ERR WmpDecAppValidateArgs(WMPDECAPPARGS* args)
{
    ERR err = WMP_errSuccess;

    Test(NULL != args->szInputFile, WMP_errInvalidParameter);
    Test(NULL != args->szOutputFile, WMP_errInvalidParameter);
    //Test(GUID_PKPixelFormatDontCare != args->enPixelFormat, WMP_errInvalidParameter);

Cleanup:
    return err;
}

ERR WmpDecAppParseArgs(int argc, char* argv[], WMPDECAPPARGS* args)
{
    ERR err = WMP_errSuccess;

    int c = 0, i = 1;
    // char* arg = NULL;

    static const PKPixelFormatGUID* pixelFormat[] =
    {
        &GUID_PKPixelFormat24bppRGB,

        &GUID_PKPixelFormatBlackWhite,

        &GUID_PKPixelFormat8bppGray,
        &GUID_PKPixelFormat16bppGray,
        &GUID_PKPixelFormat16bppGrayFixedPoint,
        &GUID_PKPixelFormat16bppGrayHalf,
        &GUID_PKPixelFormatDontCare, // &GUID_PKPixelFormat32bppGray,
        &GUID_PKPixelFormat32bppGrayFixedPoint,
        &GUID_PKPixelFormat32bppGrayFloat,

        &GUID_PKPixelFormat24bppRGB,
        &GUID_PKPixelFormat48bppRGB,
        &GUID_PKPixelFormat48bppRGBFixedPoint,
        &GUID_PKPixelFormat48bppRGBHalf,
        &GUID_PKPixelFormatDontCare, // &GUID_PKPixelFormat96bppRGB,
        &GUID_PKPixelFormat96bppRGBFixedPoint,
        &GUID_PKPixelFormat128bppRGBFloat,

        &GUID_PKPixelFormat32bppRGBE,
        &GUID_PKPixelFormat32bppCMYK,
        &GUID_PKPixelFormat64bppCMYK,

        &GUID_PKPixelFormat12bppYUV420,
        &GUID_PKPixelFormat16bppYUV422,
        &GUID_PKPixelFormat24bppYUV444,

//        &GUID_PKPixelFormat32bppRGBA,
        &GUID_PKPixelFormat32bppBGRA,
        &GUID_PKPixelFormat64bppRGBA,
        &GUID_PKPixelFormat64bppRGBAFixedPoint,
        &GUID_PKPixelFormat64bppRGBAHalf,
        &GUID_PKPixelFormatDontCare, // &GUID_PKPixelFormat128bppRGBA,
        &GUID_PKPixelFormat128bppRGBAFixedPoint,
        &GUID_PKPixelFormat128bppRGBAFloat,
        &GUID_PKPixelFormat16bppRGB555,
        &GUID_PKPixelFormat16bppRGB565,
        &GUID_PKPixelFormat32bppRGB101010,
        &GUID_PKPixelFormat40bppCMYKAlpha,
        &GUID_PKPixelFormat80bppCMYKAlpha,
        &GUID_PKPixelFormat32bppBGR,
        &GUID_PKPixelFormat32bppPBGRA,
        &GUID_PKPixelFormat64bppPRGBA,
        &GUID_PKPixelFormat128bppPRGBAFloat,
    };

    size_t InvalidPF[9] = {6, 13, 19, 20, 21, 26, 35, 36, 37};
    int k;

    WmpDecAppInitDefaultArgs(args);

    while(i < argc && argv[i][0] == '-')
//    while (EOF != (c = argit(argc, argv, "i:o:c:ptv", &arg)))
    {
         /* separate out the no-argument switches */
        switch ((c = argv[i][1])) {
            case 't':
                // NOOP - now we always print timing info
                break;

            case 'v':
                args->bVerbose = !FALSE;
                break;

            case 'C':
                args->bIgnoreOverlap = TRUE;
                break;

            case 'f':
                args->bfBitstreamFormat = FREQUENCY;
                break;

            default:
                i ++;
                if (i == argc || argv[i][0] == '-') // need more info
                    Call(WMP_errInvalidArgument);

                switch (c)
                {
                case 'i':
                    args->szInputFile= argv[i];
                    break;

                case 'o':
                    args->szOutputFile = argv[i];
                    break;

                case 'p':
                    args->cPostProcStrength = (U8)atoi(argv[i]);
                    break;

                case 'c':
                {
                    size_t idxPF = (size_t)atol(argv[i]);

                    FailIf(sizeof2(pixelFormat) <= idxPF, WMP_errUnsupportedFormat);

                    for (k = 0; k < 9; k++)
                    {
                        if (InvalidPF[k] == idxPF)
                        {
                            printf("*** ERROR: Unsupported format in JPEG XR ***\n");
                            Call(WMP_errInvalidArgument);
                        }
                    }

                    args->guidPixFormat = *pixelFormat[idxPF];

                    break;
                }

/*                case 'R':
                    args->bFlagRGB_BGR = (Bool)atoi(argv[i]);
                    break;
*/
                case 'a':
                    args->uAlphaMode = (U8)atoi(argv[i]);
                    break;

                case 's':
                    args->sbSubband = (SUBBAND)atoi(argv[i]);
                    break;

                case 'r': // Region decode
                    if(i + 3 >= argc || argv[i + 1][0] == '-' || argv[i + 2][0] == '-' || argv[i + 3][0] == '-') // not a valid region
                        Call(WMP_errInvalidArgument);

                    args->rTopY = (size_t)atoi(argv[i]);
                    args->rLeftX = (size_t)atoi(argv[i + 1]);
                    args->rHeight = (size_t)atoi(argv[i + 2]);
                    args->rWidth = (size_t)atoi(argv[i + 3]);
                    i += 3;

                    break;

                case 'T': // thumnail decode
                    args->tThumbnailFactor = (size_t)atoi(argv[i]);
                    if (args->tThumbnailFactor == 0) {  // skip flexbits
                        args->tThumbnailFactor = SKIPFLEXBITS;
                    }
                    break;

                case 'O': // orientation
                    args->oOrientation = (atoi(argv[i]) < 8 ? atoi(argv[i]) : O_NONE);
                    break;

                default:
                    Call(WMP_errInvalidArgument);
                    break;
            }
        }

        i ++;
    }

    Call(WmpDecAppValidateArgs(args));

Cleanup:
    if (WMP_errSuccess != err)
    {
        WmpDecAppUsage(argv[0]);
    }
    return err;
}

//================================================================
// Encoder factory on file extension
//================================================================
ERR WmpDecAppCreateEncoderFromExt(
    PKCodecFactory* pCFactory,
    const char* szExt,
    PKImageEncode** ppIE)
{
    ERR err = WMP_errSuccess;
    const PKIID* pIID = NULL;

    UNREFERENCED_PARAMETER( pCFactory );

    // get encod PKIID
    Call(GetTestEncodeIID(szExt, &pIID));

    // Create encoder
    Call(PKTestFactory_CreateCodec(pIID, ppIE));

Cleanup:
    return err;
}

//================================================================
// main function
//================================================================
int
#ifndef __ANSI__
__cdecl
#endif // __ANSI__
main(int argc, char* argv[])
{
    ERR err = WMP_errSuccess;

    PKFactory* pFactory = NULL;
    PKCodecFactory* pCodecFactory = NULL;
    PKImageDecode* pDecoder = NULL;

    WMPDECAPPARGS args = {0};
    char* pExt = NULL;
    U32 cFrame = 0;
    U32 i = 0;
    PKPixelInfo PI;
//    static size_t cChannels[CFT_MAX] = {1, 3, 3, 3, 4, 4, -1, 3, 3, -1};

    //================================
    // parse command line parameters
    if (1 == argc)
    {
        WmpDecAppUsage(argv[0]);
        return 0;
    }

    Call(WmpDecAppParseArgs(argc, argv, &args));
    if (args.bVerbose)
    {
        WmpDecAppShowArgs(&args);
    }

    //================================
    pExt = strrchr(args.szOutputFile, '.');
    FailIf(NULL == pExt, WMP_errUnsupportedFormat);

    //================================
    Call(PKCreateFactory(&pFactory, PK_SDK_VERSION));

    Call(PKCreateCodecFactory(&pCodecFactory, WMP_SDK_VERSION));
    Call(pCodecFactory->CreateDecoderFromFile(args.szInputFile, &pDecoder));

    //==== set default color format
    if(IsEqualGUID(&args.guidPixFormat, &GUID_PKPixelFormatDontCare)) {
        // take deocder color format and try to look up better one
        // (e.g. 32bppBGR -> 24bppBGR etc.)
        PKPixelInfo newPI;
        newPI.pGUIDPixFmt = PI.pGUIDPixFmt = &pDecoder->guidPixFormat;
        Call(PixelFormatLookup(&newPI, LOOKUP_FORWARD));
        Call(PixelFormatLookup(&newPI, LOOKUP_BACKWARD_TIF));
        args.guidPixFormat = *newPI.pGUIDPixFmt;
    }
    else
        PI.pGUIDPixFmt = &args.guidPixFormat;

//    pDecoder->WMP.wmiI.bRGB = args.bFlagRGB_BGR;

    // == color transcoding,
    if(IsEqualGUID(&args.guidPixFormat, &GUID_PKPixelFormat8bppGray) || IsEqualGUID(&args.guidPixFormat, &GUID_PKPixelFormat16bppGray)){ // ** => Y transcoding
        pDecoder->guidPixFormat = args.guidPixFormat;
        pDecoder->WMP.wmiI.cfColorFormat = Y_ONLY;
    }
    else if(IsEqualGUID(&args.guidPixFormat, &GUID_PKPixelFormat24bppRGB) && pDecoder->WMP.wmiI.cfColorFormat == CMYK){ // CMYK = > RGB
        pDecoder->WMP.wmiI.cfColorFormat = CF_RGB;
        pDecoder->guidPixFormat = args.guidPixFormat;
        pDecoder->WMP.wmiI.bRGB = 1; //RGB
    }

    PixelFormatLookup(&PI, LOOKUP_FORWARD);

    if(255 == args.uAlphaMode)//user didn't set
    {
        if(!!(PI.grBit & PK_pixfmtHasAlpha))
            args.uAlphaMode = 2;//default is image & alpha for formats with alpha
        else
            args.uAlphaMode = 0;//otherwise, 0
    }

    pDecoder->WMP.wmiSCP.bfBitstreamFormat = args.bfBitstreamFormat;
    pDecoder->WMP.wmiSCP.uAlphaMode = args.uAlphaMode;
    pDecoder->WMP.wmiSCP.sbSubband = args.sbSubband;
    pDecoder->WMP.bIgnoreOverlap = args.bIgnoreOverlap;

    pDecoder->WMP.wmiI.cfColorFormat = PI.cfColorFormat;

    pDecoder->WMP.wmiI.bdBitDepth = PI.bdBitDepth;
    pDecoder->WMP.wmiI.cBitsPerUnit = PI.cbitUnit;

    //==== Validate thumbnail decode parameters =====
    pDecoder->WMP.wmiI.cThumbnailWidth = pDecoder->WMP.wmiI.cWidth;
    pDecoder->WMP.wmiI.cThumbnailHeight = pDecoder->WMP.wmiI.cHeight;
    pDecoder->WMP.wmiI.bSkipFlexbits = FALSE;
    if(args.tThumbnailFactor > 0 && args.tThumbnailFactor != SKIPFLEXBITS){
        size_t tSize = ((size_t)1 << args.tThumbnailFactor);

        pDecoder->WMP.wmiI.cThumbnailWidth = (pDecoder->WMP.wmiI.cWidth + tSize - 1) / tSize;
        pDecoder->WMP.wmiI.cThumbnailHeight = (pDecoder->WMP.wmiI.cHeight + tSize - 1) / tSize;

        if(pDecoder->WMP.wmiI.cfColorFormat == YUV_420 || pDecoder->WMP.wmiI.cfColorFormat == YUV_422){ // unsupported thumbnail format
            pDecoder->WMP.wmiI.cfColorFormat = YUV_444;
        }
    }
    else if (args.tThumbnailFactor == SKIPFLEXBITS) {
        pDecoder->WMP.wmiI.bSkipFlexbits = TRUE;
    }

    if(args.rWidth == 0 || args.rHeight == 0){ // no region decode
        args.rLeftX = args.rTopY = 0;
        args.rWidth = pDecoder->WMP.wmiI.cThumbnailWidth;
        args.rHeight = pDecoder->WMP.wmiI.cThumbnailHeight;
    }
    pDecoder->WMP.wmiI.cROILeftX = args.rLeftX;
    pDecoder->WMP.wmiI.cROITopY = args.rTopY;
    pDecoder->WMP.wmiI.cROIWidth = args.rWidth;
    pDecoder->WMP.wmiI.cROIHeight = args.rHeight;

    pDecoder->WMP.wmiI.oOrientation = args.oOrientation;

    pDecoder->WMP.wmiI.cPostProcStrength = args.cPostProcStrength;

    pDecoder->WMP.wmiSCP.bVerbose = args.bVerbose;

    Call(pDecoder->GetFrameCount(pDecoder, &cFrame));

    //================================
    for (i = 0; ; ++i)
    {
        struct WMPStream* pEncodeStream = NULL;
        PKImageEncode* pEncoder = NULL;

        PKFormatConverter* pConverter = NULL;

        Float rX = 0.0, rY = 0.0;
        PKRect rect = {0, 0, 0, 0};

        //================================
        Call(pCodecFactory->CreateFormatConverter(&pConverter));

        Call(pConverter->Initialize(pConverter, pDecoder, pExt, args.guidPixFormat));

        //================================
        Call(pFactory->CreateStreamFromFilename(&pEncodeStream, args.szOutputFile, "wb"));
        Call(WmpDecAppCreateEncoderFromExt(pCodecFactory, pExt, &pEncoder));

		if(pEncoder->bWMP)
			Call(pEncoder->Initialize(pEncoder, pEncodeStream, &args.wmiSCP, sizeof(args.wmiSCP)));
		else
			Call(pEncoder->Initialize(pEncoder, pEncodeStream, NULL, 0));

        //================================
        Call(pEncoder->SetPixelFormat(pEncoder, args.guidPixFormat));
        pEncoder->WMP.wmiSCP.bBlackWhite = pDecoder->WMP.wmiSCP.bBlackWhite;

        //Call(pDecoder->GetSize(pDecoder, &rect.Width, &rect.Height));
        rect.Width = (I32)(pDecoder->WMP.wmiI.cROIWidth);
        rect.Height = (I32)(pDecoder->WMP.wmiI.cROIHeight);

        if(args.oOrientation > O_FLIPVH){ // allocate memory for rotated image!
            I32 bah = rect.Width;

            rect.Width = rect.Height;
            rect.Height = bah;
        }

        Call(pEncoder->SetSize(pEncoder, rect.Width, rect.Height));

        Call(pDecoder->GetResolution(pDecoder, &rX, &rY));
        if(args.oOrientation > O_FLIPVH)
            Call(pEncoder->SetResolution(pEncoder, rY, rX));
        else
            Call(pEncoder->SetResolution(pEncoder, rX, rY));

        if(pEncoder->bWMP && args.tThumbnailFactor > 0){
            printf("-T can not be used for compressed domain operation!\n");
            return 0;
        }

        //================================
		pEncoder->WriteSource = PKImageEncode_Transcode;
        Call(pEncoder->WriteSource(pEncoder, pConverter, &rect));

        //================================
//        Call(pEncoder->Terminate(pEncoder));
        pEncoder->Release(&pEncoder);

        // multi-frame support NYI
        if (i + 1 == cFrame)
        {
            break;
        }

        Call(pDecoder->SelectFrame(pDecoder, i + 1));
    }

    pDecoder->Release(&pDecoder);

Cleanup:
    if (WMP_errUnsupportedFormat == err)
    {
        printf("*** ERROR: Unsupported format in JPEG XR ***\n");
    }

    return (int)err;
}


text:
/*********************************************************************
 This is a library for OLEDS

 Written by Mark Winney.
 BSD license, check license.txt for more information
 All text above, and the splash screen must be included in any redistribution
 *********************************************************************/

#ifdef __AVR__
#include <avr/pgmspace.h>
#elif defined ESP8266 //Added for compatibility with ESP8266 BOARD
#include <pgmspace.h>
#endif
#ifndef __SAM3X8E__
#ifndef ESP8266
#include <util/delay.h>
#endif
#endif
#include <stdlib.h>

//#include "Adafruit_GFX.h"
#include "ESP8266_SSD1322.h"
#include "oled_menu.h"

#define NOINVERT	false

extern const uint8_t selectbar_top[];
extern const uint8_t selectbar_bottom[];
extern const uint8_t menu_default[];
extern const uint8_t selectbar_topWidthPixels;

OLEDMenu::OLEDMenu (ESP8266_SSD1322& display) :
    m_display (display)
{
}

bool
OLEDMenu::downOption (void)
{
Serial.print("downOption:");
Serial.println(menu_selected);

//Serial.println("MenuManager::downOption(void)");
  menus[menu_selected]->option_selected++;
  uint8_t sel = menus[menu_selected]->option_selected;

  if (sel >= menus[menu_selected]->num_options)
  {
    menus[menu_selected]->option_selected = 0;
  }
  return true;
}

bool
OLEDMenu::upOption ()
{
Serial.print("upOption:");
Serial.println(menu_selected);

  //Serial.println("MenuManager::upOption(void)");
  menus[menu_selected]->option_selected--;
  uint8_t sel = menus[menu_selected]->option_selected;

  if (sel >= menus[menu_selected]->num_options)
  {
    menus[menu_selected]->option_selected = menus[menu_selected]->num_options
	- 1;
  }
  return true;
}

bool
OLEDMenu::selectOption (void)
{
  // Move to the next menu, assuming the option selected is a menu

//Serial.println("MenuManager::selectOption(void)");
  int8_t optSel = menus[menu_selected]->option_selected;
  pFunc funct = menus[menu_selected]->options[optSel]->func;
  bool subMenu = (funct == NULL);
Serial.println("-------------------------");
Serial.print("menu_selected=");
Serial.println(menu_selected);
Serial.print("optSel=");
Serial.println(optSel);
Serial.print("subMenu=");
Serial.println(subMenu);

  if (subMenu == true)
  {
    // Get the index to the sub menu
    int8_t menuIndex = menus[menu_selected]->options[optSel]->menu_index;

Serial.print("menuIndex=");
Serial.println(menuIndex);
    // See if this is the exit option
    if (menuIndex == MENU_EXIT)
    {
Serial.print("menu_selected=");
Serial.println(menu_selected);
      menu_selected = menus[menu_selected]->prev_menu;
Serial.print("menu_selected=");
Serial.println(menu_selected);
      // Reset the option back to zero
      //			mMenus[mMenuSelected]->mOptionSelected = 0;
    }
    else
    {
      // Store where you came from into the new menu so can get back when exit menu
      uint8_t tempMenu = menu_selected;

      // Change to the new menu
      menu_selected = menuIndex;

      // Store where you came from into the new menu so can get back when exit menu
      menus[menu_selected]->prev_menu = tempMenu;

      // Reset the option back to zero
      menus[menu_selected]->option_selected = 0;

    }
  }
  else
  {
    // Must call the function setup
    funct ();
  }
  return true;
}

void
OLEDMenu::initMenu (uint8_t num)
{
  num_menus = num;
  menus = new s_menu*[num]; // Allocate space for the menus.  Array of pointers to menus
  menu_selected = 0;
}

// Create a menu by allocating space
void
OLEDMenu::createMenu (int8_t index, int8_t num_options, const char *name)
{
  menus[index] = new s_menu; // allocate space for the menu
  menus[index]->name = name; // Store pointer to option name
  menus[index]->options = new s_option*[num_options]; // Allocate array of pointers to options
  menus[index]->num_options = num_options;
  menus[index]->option_selected = 0;
}

void
OLEDMenu::createOption (int8_t menu_index, int8_t opt_index, const char *name,
			const uint8_t *icon, pFunc actionFunc)
{
  menus[menu_index]->options[opt_index] = new s_option; // allocate space for the option
  menus[menu_index]->options[opt_index]->func = actionFunc;
  menus[menu_index]->options[opt_index]->icon = icon;
  menus[menu_index]->options[opt_index]->name = name;
  menus[menu_index]->options[opt_index]->menu_index = -1;
}

void
OLEDMenu::createOption (int8_t menu_index, int8_t opt_index, const char *name,
			const uint8_t *icon, uint8_t prev_menu_index)
{
  menus[menu_index]->options[opt_index] = new s_option; // allocate space for the option
  menus[menu_index]->options[opt_index]->func = NULL;
  menus[menu_index]->options[opt_index]->icon = icon;
  menus[menu_index]->options[opt_index]->name = name;
  menus[menu_index]->options[opt_index]->menu_index = prev_menu_index;
}

void
OLEDMenu::createOption (int8_t menu_index, int8_t opt_index, pFunc actionFunc,
			uint8_t prev_menu_index)
{
  menus[menu_index]->options[opt_index] = new s_option; // allocate space for the option
  menus[menu_index]->options[opt_index]->func = actionFunc;
//	menus[menu_index]->options[opt_index]->icon = icon;
//	menus[menu_index]->options[opt_index]->name = name;
  menus[menu_index]->options[opt_index]->menu_index = prev_menu_index;
}

void
OLEDMenu::createOption (int8_t menu_index, int8_t opt_index, const char *name,
			uint8_t prev_menu_index)
{
  menus[menu_index]->options[opt_index] = new s_option; // allocate space for the option
//	menus[menu_index]->options[opt_index]->func = actionFunc;
//	menus[menu_index]->options[opt_index]->icon = icon;
  menus[menu_index]->options[opt_index]->name = name;
  menus[menu_index]->options[opt_index]->menu_index = prev_menu_index;
}

bool
OLEDMenu::updateMenu ()
{
  bool bAnimating = false;

  // Get the index to the sub menu
//	int8_t optSel = menus[menu_selected]->option_selected;
//	int8_t menuIndex = menus[menu_selected]->options[optSel]->menu_index;
//
//	// See if this option was to display a paged display
//	if (menuIndex == MENU_PAGED_NEXT_PREV)
//	{
//Serial.println("MENU_PAGED_NEXT_PREV");
//	}
//	else
  {
    // Display as regular icon
    // Get the first menu to start with...change later to get current
    bAnimating = menu_drawIcon ();
  }

  return bAnimating;
}

bool
OLEDMenu::menu_drawIcon ()
{
  const int16_t displayWidth = m_display.width();
  const int16_t displayHeight = m_display.height();

  bool bAnimating = true;
//	static int animX = 64;

//	int x = 64;
  int x = displayWidth / 2;
  x -= 48 * menus[menu_selected]->option_selected;

  {
    int8_t speed;
    if (x > animX)
    {
      speed = ((x - animX) / 4) + 1;
      if (speed > 16)
	speed = 16;
      animX += speed;
      if (x <= animX)
	animX = x;
    }
    else if (x < animX)
    {
      speed = ((animX - x) / 4) + 1;
      if (speed > 16)
	speed = 16;
      animX -= speed;
      if (x >= animX)
	animX = x;
    }
    else
    {
      bAnimating = false;
    }
  }

  x = animX - 16;

  // Copy the data from PROGMEM...max 20 chars
  char tmpStr[20] = { 0 };
  strcpy_P (tmpStr, menus[menu_selected]->name);
  m_display.drawCentreString (tmpStr, displayWidth / 2, 0, textSize);

  // Create image struct
  // FIX: struct uses heap, should use stack
  uint8_t fix = selectbar_topWidthPixels;
  s_image img = newImage((displayWidth / 2) - (selectbar_topWidthPixels / 2),
			 14, selectbar_top, fix, 8, WHITE, NOINVERT);

  // Draw ...
  ultraFastDrawBitmap (&img);

  // Draw ...
  img.y = 42;
  img.bitmap = selectbar_bottom;
  ultraFastDrawBitmap(&img);

  img.y = 16;
  img.width = 32;
  img.height = 32;

  // Display each menu option
  for (byte i = 0; i < menus[menu_selected]->num_options; i++)
  {
    if (x < displayWidth && x > -32)
    {
      img.x = x;
      img.bitmap =
	  menus[menu_selected]->options[i]->icon != NULL ?
	      menus[menu_selected]->options[i]->icon : menu_default;
      ultraFastDrawBitmap(&img);
    }
    x += 48;
  }

  uint8_t sel_opt = menus[menu_selected]->option_selected;
  strcpy_P (tmpStr, menus[menu_selected]->options[sel_opt]->name);
  m_display.drawString(tmpStr, 0, displayHeight - 8, textSize);

  return bAnimating;
}

void
OLEDMenu::ultraFastDrawBitmap (s_image* image)
{
  m_display.fastDrawBitmap(image->x, image->y, image->bitmap, image->width,
			    image->height, image->foreColour);
}

void
OLEDMenu::resetMenu ()
{
  // reset all the options back to default 0
  menu_selected = 0;

  for (int menuLoop = 0; menuLoop < num_menus; menuLoop++)
  {
    menus[menuLoop]->option_selected = 0;
  }

  // Reset Animation
  animX = SSD1322_LCDWIDTH / 2;
}

void
OLEDMenu::setTextSize (uint8_t size)
{
  textSize = size;
}
// --------------------------------------------------------------------------------------------//

OLEDPage::OLEDPage (ESP8266_SSD1322& display, int8_t itemsPerPage) :
    m_display (display), m_currentMenuOption (NONE), m_currentPage (0), m_itemsPerPage (
	itemsPerPage)
{
}

void OLEDPage::begin()
{
  m_currentMenuOption = NONE;
  m_currentPage = 0;
}

void
OLEDPage::display (uint8_t currentPage)
{
  // Save the current page in the class
  m_currentPage = currentPage;

  if (m_currentMenuOption == NEXT_PAGE)
  {
    m_display.setTextColor (BLACK, WHITE);
  }
  else
  {
    // Display "Next Page" and "Exit" on each page
    m_display.setTextColor (WHITE);
  }

  // Only display this if more then 1 page
  m_display.setCursor (0, 0);
  m_display.print (F ("<Next Page>"));

  if (currentPage > 0)
  {
    if (m_currentMenuOption == PREV_PAGE)
    {
      m_display.setTextColor (BLACK, WHITE);
    }
    else
    {
      // Display "Next Page" and "Exit" at the bottom of each page
      m_display.setTextColor (WHITE);
    }

    // Only display this not on page 1
    m_display.setCursor (70, 0);
    m_display.print (F ("<Prev Page>"));
  }

  if (m_currentMenuOption == EXIT_PAGE)
  {
    m_display.setTextColor (BLACK, WHITE);
  }
  else
  {
    // Display "Next Page" and "Exit" at the bottom of each page
    m_display.setTextColor (WHITE);
  }

  m_display.setCursor (140, 0);
  m_display.print (F ("<Exit>"));
}

// returns true if we are going into the menu else false
bool
OLEDPage::handleUpOption (int8_t& selected)
{
Serial.print("handleUpOption:");
Serial.println(selected);
  // If we deduct 1 from this do we exit from the
  // page data and head into the menu.  We know this
  // if the selected passed is < 0

  int8_t newSel = selected - 1;

  // Check if into the menu area.
  if (newSel < 0)
  {
    // Must be into the menu at top of page now
    m_currentMenuOption++;

    // Check the current page and if we are
    // on page 1 then the Prev option is not displayed
    // so move straight to the exit option.
    if (m_currentPage == 0 && m_currentMenuOption == PREV_PAGE)
    {
      m_currentMenuOption++;
    }

    // If we are past the exit page then go back to the
    // Next Page option
    if (m_currentMenuOption > EXIT_PAGE)
    {
      m_currentMenuOption = NEXT_PAGE;
    }
//Serial.println("Into Menu");
    return true;
  }
  else
  {
    // Not in the menu, but in the list so send back a new
    // selected item.
    selected--;

//		if (selected < 0)
//		{
//		  // Roll to last page
//			selected = stationSize - 1;
//		}
  }

  return false;
}

// returns true if we are going into the menu else false
bool
OLEDPage::handleDownOption (int8_t& selected)
{
Serial.print("handleDownOption:");
Serial.println(selected);
  // Check if we are in the menu and if the down is selected
  // go back into the list and get out of the menu.
  if (m_currentMenuOption != NONE)
  {
    // If we have just exited the menu then
    // reset to top of the page
    selected = 0;
    m_currentMenuOption = NONE;
    return true;
  }
  else
  {
    // Move to the next item on the page
    selected++;

    // See if we are on the last page and
    // make sure when we move past the end
    // of the list that we go back to the start.
    bool lastPage = (m_currentPage == (m_totalItemsInList / m_itemsPerPage));
    if (lastPage)
    {
      uint8_t lastItem = m_totalItemsInList - (m_currentPage * m_itemsPerPage)
	  - 1;

      if (selected > lastItem)
      {
	selected = 0;
      }
    }
    else
    {
      // Rotate back to start of the page if
      // we reached the end.
      if (selected > (m_itemsPerPage - 1))
      {
	selected = 0;
      }
    }
  }

  return false;
}

// returns true if we are going into the menu else false
OLEDPage::page_options
OLEDPage::handleSelectOption (int8_t& currentPageNumber)
{
  Serial.println (m_currentMenuOption);

  if (m_currentMenuOption == NEXT_PAGE)
  {
    // Make sure don't go past last page
    bool lastPage = (m_currentPage == (m_totalItemsInList / m_itemsPerPage));
    if (!lastPage)
    {
      currentPageNumber++;
    }
  }
  else if (m_currentMenuOption == PREV_PAGE)
  {
    currentPageNumber--;

    // If this is the first page then no Prev Page
    // will be displayed so reset to Next Page
    if (currentPageNumber == 0)
    {
      m_currentMenuOption = NEXT_PAGE;
    }
  }
  else if (m_currentMenuOption == EXIT_PAGE)
  {
    m_currentMenuOption = NONE;
    return EXIT_PAGE;
  }

  return (page_options) m_currentMenuOption;
}

// --------------------------------------------------------------------------------------------//

OLEDKeyboard::OLEDKeyboard(ESP8266_SSD1322& display): m_display(display)
{
}

void OLEDKeyboard::display(uint8_t currentPage)
{
  uint8_t xpos = 50;
  uint8_t ypos = 32;

  m_display.setTextSize(1);
  m_display.setTextColor(WHITE);
  m_display.setCursor(xpos, ypos);

  // Display the numbers 0-9 at top
  for (uint8_t i = 0; i < 10; i++)
  {
    m_display.setCursor(xpos + 10, ypos);
    m_display.write(48 + i);
  }
}
void OLEDKeyboard::handleUpOption(int8_t& selected)
{

}
void OLEDKeyboard::handleDownOption(int8_t& selected)
{

}
void OLEDKeyboard::handleSelectOption()
{

}

redpajama_set_name: RedPajamaGithub


text:
print('Problem 8: Write a JavaScript function that replaces in a HTML document given as string all the tags … with corresponding tags [URL=…]…/URL].');

var html = '
Please visit our site to choose a training course. Also visit our forum to discuss the courses.
';

function replaceLinks(text) {
    var arr = [];
    var startLink = "";
    var link = "";
    var indexStart = -1;
    var indexEnd = -1;
    var newStr = "";
    while (true) {
        indexStart = text.indexOf(startLink, indexStart + 1);
        indexEnd = text.indexOf(endLink, indexStart + 1);
        if (indexStart == -1 || indexEnd == -1) {
            break;
        }
        link = text.substring(indexStart, indexEnd + 2);
        newStr = text.replace(link, build(extractURL(link), extractAnchorContent(link)));
        text = newStr;

    }
    return text;
};

function extractURL(anchor) {
    var start = '"';
    var http = '';
    var startIndex = anchor.indexOf('="');
    for (var i = 0; i < anchor.length; i++) {
        if (i >= startIndex + 2) {
            if (anchor[i] == start) {
                break;
            }
            http = http + anchor[i];
        }
    }
    return http;
};

function extractAnchorContent(anchor) {
    var start = anchor.indexOf('>', 0);
    var end = anchor.indexOf('<', 1);
    var content = anchor.substring(start + 1, end);
    return content;
}

function build(protocol, content) {
    var url = '[URL=...]....[/URL]';
    var urlTag = url.replace('...', protocol);
    var urlFinal = urlTag.replace('....', content);
    return urlFinal;
}

jsConsole.writeLine(replaceLinks(html));
console.log(replaceLinks(html));


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Taxonomy and Pathology of Cylindrocladium (Calonectria) and Allied Genera (St Paul) 94 (2002)

#### Original name
Nectria indusiata Seaver

### Remarks
null


text:
"use strict";

const Connection = require("../lib/");

const execute = async () => {
    const conn = new Connection({ logLevel: "INFO" });
    await conn.login({
        username: "john@demo.com",
        password: "*******",
        security_token: "G6oNrdsw***********"
    });
    const populateResult = await conn.collection("Account").select("Account.Name").joinTable([{table: "Contact", fields: ["Name"]}]).populateParent({
        child: {
            table: "Contact",
            field: "accountId"
        },
        parent: {
            field: "Id"
        }
    }).run();
    console.log("Result : ", populateResult);
    await conn.logout();
};
execute();


text:
// +build !providerless

package azure

import (
	"context"
	"fmt"
	"strings"

	"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network"
	"github.com/Azure/go-autorest/autorest/to"

	"k8s.io/apimachinery/pkg/types"
	cloudprovider "k8s.io/cloud-provider"
	"k8s.io/klog"
	utilnet "k8s.io/utils/net"
)

// copied to minimize the number of cross reference
// and exceptions in publishing and allowed imports.
const (
	routeNameFmt       = "%s____%s"
	routeNameSeparator = "____"
)

// ListRoutes lists all managed routes that belong to the specified clusterName
func (az *Cloud) ListRoutes(ctx context.Context, clusterName string) ([]*cloudprovider.Route, error) {
	klog.V(10).Infof("ListRoutes: START clusterName=%q", clusterName)
	routeTable, existsRouteTable, err := az.getRouteTable(cacheReadTypeDefault)
	routes, err := processRoutes(az.ipv6DualStackEnabled, routeTable, existsRouteTable, err)
	if err != nil {
		return nil, err
	}

	// Compose routes for unmanaged routes so that node controller won't retry creating routes for them.
	unmanagedNodes, err := az.GetUnmanagedNodes()
	if err != nil {
		return nil, err
	}
	az.routeCIDRsLock.Lock()
	defer az.routeCIDRsLock.Unlock()
	for _, nodeName := range unmanagedNodes.List() {
		if cidr, ok := az.routeCIDRs[nodeName]; ok {
			routes = append(routes, &cloudprovider.Route{
				Name:            nodeName,
				TargetNode:      mapRouteNameToNodeName(az.ipv6DualStackEnabled, nodeName),
				DestinationCIDR: cidr,
			})
		}
	}

	return routes, nil
}

// Injectable for testing
func processRoutes(ipv6DualStackEnabled bool, routeTable network.RouteTable, exists bool, err error) ([]*cloudprovider.Route, error) {
	if err != nil {
		return nil, err
	}
	if !exists {
		return []*cloudprovider.Route{}, nil
	}

	var kubeRoutes []*cloudprovider.Route
	if routeTable.RouteTablePropertiesFormat != nil && routeTable.Routes != nil {
		kubeRoutes = make([]*cloudprovider.Route, len(*routeTable.Routes))
		for i, route := range *routeTable.Routes {
			instance := mapRouteNameToNodeName(ipv6DualStackEnabled, *route.Name)
			cidr := *route.AddressPrefix
			klog.V(10).Infof("ListRoutes: * instance=%q, cidr=%q", instance, cidr)

			kubeRoutes[i] = &cloudprovider.Route{
				Name:            *route.Name,
				TargetNode:      instance,
				DestinationCIDR: cidr,
			}
		}
	}

	klog.V(10).Info("ListRoutes: FINISH")
	return kubeRoutes, nil
}

func (az *Cloud) createRouteTableIfNotExists(clusterName string, kubeRoute *cloudprovider.Route) error {
	if _, existsRouteTable, err := az.getRouteTable(cacheReadTypeDefault); err != nil {
		klog.V(2).Infof("createRouteTableIfNotExists error: couldn't get routetable. clusterName=%q instance=%q cidr=%q", clusterName, kubeRoute.TargetNode, kubeRoute.DestinationCIDR)
		return err
	} else if existsRouteTable {
		return nil
	}
	return az.createRouteTable()
}

func (az *Cloud) createRouteTable() error {
	routeTable := network.RouteTable{
		Name:                       to.StringPtr(az.RouteTableName),
		Location:                   to.StringPtr(az.Location),
		RouteTablePropertiesFormat: &network.RouteTablePropertiesFormat{},
	}

	klog.V(3).Infof("createRouteTableIfNotExists: creating routetable. routeTableName=%q", az.RouteTableName)
	err := az.CreateOrUpdateRouteTable(routeTable)
	if err != nil {
		return err
	}

	// Invalidate the cache right after updating
	az.rtCache.Delete(az.RouteTableName)
	return nil
}

// CreateRoute creates the described managed route
// route.Name will be ignored, although the cloud-provider may use nameHint
// to create a more user-meaningful name.
func (az *Cloud) CreateRoute(ctx context.Context, clusterName string, nameHint string, kubeRoute *cloudprovider.Route) error {
	// Returns  for unmanaged nodes because azure cloud provider couldn't fetch information for them.
	var targetIP string
	nodeName := string(kubeRoute.TargetNode)
	unmanaged, err := az.IsNodeUnmanaged(nodeName)
	if err != nil {
		return err
	}
	if unmanaged {
		if az.ipv6DualStackEnabled {
			//TODO (khenidak) add support for unmanaged nodes when the feature reaches beta
			return fmt.Errorf("unmanaged nodes are not supported in dual stack mode")
		}
		klog.V(2).Infof("CreateRoute: omitting unmanaged node %q", kubeRoute.TargetNode)
		az.routeCIDRsLock.Lock()
		defer az.routeCIDRsLock.Unlock()
		az.routeCIDRs[nodeName] = kubeRoute.DestinationCIDR
		return nil
	}

	klog.V(2).Infof("CreateRoute: creating route. clusterName=%q instance=%q cidr=%q", clusterName, kubeRoute.TargetNode, kubeRoute.DestinationCIDR)
	if err := az.createRouteTableIfNotExists(clusterName, kubeRoute); err != nil {
		return err
	}
	if !az.ipv6DualStackEnabled {
		targetIP, _, err = az.getIPForMachine(kubeRoute.TargetNode)
		if err != nil {
			return err
		}
	} else {
		// for dual stack we need to select
		// a private ip that matches family of the cidr
		klog.V(4).Infof("CreateRoute: create route instance=%q cidr=%q is in dual stack mode", kubeRoute.TargetNode, kubeRoute.DestinationCIDR)
		CIDRv6 := utilnet.IsIPv6CIDRString(string(kubeRoute.DestinationCIDR))
		nodePrivateIPs, err := az.getPrivateIPsForMachine(kubeRoute.TargetNode)
		if nil != err {
			klog.V(3).Infof("CreateRoute: create route: failed(GetPrivateIPsByNodeName) instance=%q cidr=%q with error=%v", kubeRoute.TargetNode, kubeRoute.DestinationCIDR, err)
			return err
		}

		targetIP, err = findFirstIPByFamily(nodePrivateIPs, CIDRv6)
		if nil != err {
			klog.V(3).Infof("CreateRoute: create route: failed(findFirstIpByFamily) instance=%q cidr=%q with error=%v", kubeRoute.TargetNode, kubeRoute.DestinationCIDR, err)
			return err
		}
	}
	routeName := mapNodeNameToRouteName(az.ipv6DualStackEnabled, kubeRoute.TargetNode, string(kubeRoute.DestinationCIDR))
	route := network.Route{
		Name: to.StringPtr(routeName),
		RoutePropertiesFormat: &network.RoutePropertiesFormat{
			AddressPrefix:    to.StringPtr(kubeRoute.DestinationCIDR),
			NextHopType:      network.RouteNextHopTypeVirtualAppliance,
			NextHopIPAddress: to.StringPtr(targetIP),
		},
	}

	actualRoutes, err := az.ListRoutes(ctx, clusterName)
	if err != nil {
		klog.V(3).Infof("CreateRoute: creating route: failed(ListRoutes) clusterName= %q instance=%q with error=%v", clusterName, kubeRoute.TargetNode, err)
		return err
	}

	for _, actualRoute := range actualRoutes {
		if strings.EqualFold(actualRoute.Name, kubeRoute.Name) &&
			strings.EqualFold(string(actualRoute.TargetNode), string(kubeRoute.TargetNode)) &&
			strings.EqualFold(actualRoute.DestinationCIDR, kubeRoute.DestinationCIDR) {
			klog.V(2).Infof("CreateRoute: route is already existed and matched, no need to re-create or update")
			return nil
		}
	}

	klog.V(3).Infof("CreateRoute: creating route: instance=%q cidr=%q", kubeRoute.TargetNode, kubeRoute.DestinationCIDR)
	err = az.CreateOrUpdateRoute(route)
	if err != nil {
		return err
	}

	klog.V(2).Infof("CreateRoute: route created. clusterName=%q instance=%q cidr=%q", clusterName, kubeRoute.TargetNode, kubeRoute.DestinationCIDR)
	return nil
}

// DeleteRoute deletes the specified managed route
// Route should be as returned by ListRoutes
func (az *Cloud) DeleteRoute(ctx context.Context, clusterName string, kubeRoute *cloudprovider.Route) error {
	// Returns  for unmanaged nodes because azure cloud provider couldn't fetch information for them.
	nodeName := string(kubeRoute.TargetNode)
	unmanaged, err := az.IsNodeUnmanaged(nodeName)
	if err != nil {
		return err
	}
	if unmanaged {
		klog.V(2).Infof("DeleteRoute: omitting unmanaged node %q", kubeRoute.TargetNode)
		az.routeCIDRsLock.Lock()
		defer az.routeCIDRsLock.Unlock()
		delete(az.routeCIDRs, nodeName)
		return nil
	}

	klog.V(2).Infof("DeleteRoute: deleting route. clusterName=%q instance=%q cidr=%q", clusterName, kubeRoute.TargetNode, kubeRoute.DestinationCIDR)

	routeName := mapNodeNameToRouteName(az.ipv6DualStackEnabled, kubeRoute.TargetNode, string(kubeRoute.DestinationCIDR))
	err = az.DeleteRouteWithName(routeName)
	if err != nil {
		return err
	}

	klog.V(2).Infof("DeleteRoute: route deleted. clusterName=%q instance=%q cidr=%q", clusterName, kubeRoute.TargetNode, kubeRoute.DestinationCIDR)
	return nil
}

// This must be kept in sync with mapRouteNameToNodeName.
// These two functions enable stashing the instance name in the route
// and then retrieving it later when listing. This is needed because
// Azure does not let you put tags/descriptions on the Route itself.
func mapNodeNameToRouteName(ipv6DualStackEnabled bool, nodeName types.NodeName, cidr string) string {
	if !ipv6DualStackEnabled {
		return fmt.Sprintf("%s", nodeName)
	}
	return fmt.Sprintf(routeNameFmt, nodeName, cidrtoRfc1035(cidr))
}

// Used with mapNodeNameToRouteName. See comment on mapNodeNameToRouteName.
func mapRouteNameToNodeName(ipv6DualStackEnabled bool, routeName string) types.NodeName {
	if !ipv6DualStackEnabled {
		return types.NodeName(fmt.Sprintf("%s", routeName))
	}
	parts := strings.Split(routeName, routeNameSeparator)
	nodeName := parts[0]
	return types.NodeName(nodeName)

}

// given a list of ips, return the first one
// that matches the family requested
// error if no match, or failure to parse
// any of the ips
func findFirstIPByFamily(ips []string, v6 bool) (string, error) {
	for _, ip := range ips {
		bIPv6 := utilnet.IsIPv6String(ip)
		if v6 == bIPv6 {
			return ip, nil
		}
	}
	return "", fmt.Errorf("no match found matching the ipfamily requested")
}

//strips : . /
func cidrtoRfc1035(cidr string) string {
	cidr = strings.ReplaceAll(cidr, ":", "")
	cidr = strings.ReplaceAll(cidr, ".", "")
	cidr = strings.ReplaceAll(cidr, "/", "")
	return cidr
}


text:
require 'spec_helper'

describe Note, models: true do
  include RepoHelpers

  describe 'associations' do
    it { is_expected.to belong_to(:project) }
    it { is_expected.to belong_to(:noteable).touch(true) }
    it { is_expected.to belong_to(:author).class_name('User') }

    it { is_expected.to have_many(:todos).dependent(:destroy) }
  end

  describe 'modules' do
    subject { described_class }

    it { is_expected.to include_module(Participable) }
    it { is_expected.to include_module(Mentionable) }
    it { is_expected.to include_module(Awardable) }

    it { is_expected.to include_module(Gitlab::CurrentSettings) }
  end

  describe 'validation' do
    it { is_expected.to validate_presence_of(:note) }
    it { is_expected.to validate_presence_of(:project) }

    context 'when note is on commit' do
      before do
        allow(subject).to receive(:for_commit?).and_return(true)
      end

      it { is_expected.to validate_presence_of(:commit_id) }
      it { is_expected.not_to validate_presence_of(:noteable_id) }
    end

    context 'when note is not on commit' do
      before do
        allow(subject).to receive(:for_commit?).and_return(false)
      end

      it { is_expected.not_to validate_presence_of(:commit_id) }
      it { is_expected.to validate_presence_of(:noteable_id) }
    end

    context 'when noteable and note project differ' do
      subject do
        build(:note, noteable: build_stubbed(:issue),
                     project: build_stubbed(:empty_project))
      end

      it { is_expected.to be_invalid }
    end

    context 'when noteable and note project are the same' do
      subject { create(:note) }
      it { is_expected.to be_valid }
    end

    context 'when project is missing for a project related note' do
      subject { build(:note, project: nil, noteable: build_stubbed(:issue)) }
      it { is_expected.to be_invalid }
    end

    context 'when noteable is a personal snippet' do
      subject { build(:note_on_personal_snippet) }

      it 'is valid without project' do
        is_expected.to be_valid
      end
    end
  end

  describe "Commit notes" do
    let!(:note) { create(:note_on_commit, note: "+1 from me") }
    let!(:commit) { note.noteable }

    it "is accessible through #noteable" do
      expect(note.commit_id).to eq(commit.id)
      expect(note.noteable).to be_a(Commit)
      expect(note.noteable).to eq(commit)
    end

    it "saves a valid note" do
      expect(note.commit_id).to eq(commit.id)
      note.noteable == commit
    end

    it "is recognized by #for_commit?" do
      expect(note).to be_for_commit
    end

    it "keeps the commit around" do
      expect(note.project.repository.kept_around?(commit.id)).to be_truthy
    end
  end

  describe 'authorization' do
    before do
      @p1 = create(:empty_project)
      @p2 = create(:empty_project)
      @u1 = create(:user)
      @u2 = create(:user)
      @u3 = create(:user)
    end

    describe 'read' do
      before do
        @p1.project_members.create(user: @u2, access_level: ProjectMember::GUEST)
        @p2.project_members.create(user: @u3, access_level: ProjectMember::GUEST)
      end

      it { expect(Ability.allowed?(@u1, :read_note, @p1)).to be_falsey }
      it { expect(Ability.allowed?(@u2, :read_note, @p1)).to be_truthy }
      it { expect(Ability.allowed?(@u3, :read_note, @p1)).to be_falsey }
    end

    describe 'write' do
      before do
        @p1.project_members.create(user: @u2, access_level: ProjectMember::DEVELOPER)
        @p2.project_members.create(user: @u3, access_level: ProjectMember::DEVELOPER)
      end

      it { expect(Ability.allowed?(@u1, :create_note, @p1)).to be_falsey }
      it { expect(Ability.allowed?(@u2, :create_note, @p1)).to be_truthy }
      it { expect(Ability.allowed?(@u3, :create_note, @p1)).to be_falsey }
    end

    describe 'admin' do
      before do
        @p1.project_members.create(user: @u1, access_level: ProjectMember::REPORTER)
        @p1.project_members.create(user: @u2, access_level: ProjectMember::MASTER)
        @p2.project_members.create(user: @u3, access_level: ProjectMember::MASTER)
      end

      it { expect(Ability.allowed?(@u1, :admin_note, @p1)).to be_falsey }
      it { expect(Ability.allowed?(@u2, :admin_note, @p1)).to be_truthy }
      it { expect(Ability.allowed?(@u3, :admin_note, @p1)).to be_falsey }
    end
  end

  it_behaves_like 'an editable mentionable' do
    subject { create :note, noteable: issue, project: issue.project }

    let(:issue) { create(:issue, project: create(:project, :repository)) }
    let(:backref_text) { issue.gfm_reference }
    let(:set_mentionable_text) { ->(txt) { subject.note = txt } }
  end

  describe "#all_references" do
    let!(:note1) { create(:note_on_issue) }
    let!(:note2) { create(:note_on_issue) }

    it "reads the rendered note body from the cache" do
      expect(Banzai::Renderer).to receive(:cache_collection_render)
        .with([{
          text: note1.note,
          context: {
            skip_project_check: false,
            pipeline: :note,
            cache_key: [note1, "note"],
            project: note1.project,
            author: note1.author
          }
        }]).and_call_original

      expect(Banzai::Renderer).to receive(:cache_collection_render)
        .with([{
          text: note2.note,
          context: {
            skip_project_check: false,
            pipeline: :note,
            cache_key: [note2, "note"],
            project: note2.project,
            author: note2.author
          }
        }]).and_call_original

      note1.all_references.users
      note2.all_references.users
    end
  end

  describe "editable?" do
    it "returns true" do
      note = build(:note)
      expect(note.editable?).to be_truthy
    end

    it "returns false" do
      note = build(:note, system: true)
      expect(note.editable?).to be_falsy
    end
  end

  describe "cross_reference_not_visible_for?" do
    let(:private_user)    { create(:user) }
    let(:private_project) { create(:empty_project, namespace: private_user.namespace) { |p| p.team << [private_user, :master] } }
    let(:private_issue)   { create(:issue, project: private_project) }

    let(:ext_proj)  { create(:empty_project, :public) }
    let(:ext_issue) { create(:issue, project: ext_proj) }

    let(:note) do
      create :note,
        noteable: ext_issue, project: ext_proj,
        note: "mentioned in issue #{private_issue.to_reference(ext_proj)}",
        system: true
    end

    it "returns true" do
      expect(note.cross_reference_not_visible_for?(ext_issue.author)).to be_truthy
    end

    it "returns false" do
      expect(note.cross_reference_not_visible_for?(private_user)).to be_falsy
    end

    it "returns false if user visible reference count set" do
      note.user_visible_reference_count = 1

      expect(note).not_to receive(:reference_mentionables)
      expect(note.cross_reference_not_visible_for?(ext_issue.author)).to be_falsy
    end

    it "returns true if ref count is 0" do
      note.user_visible_reference_count = 0

      expect(note).not_to receive(:reference_mentionables)
      expect(note.cross_reference_not_visible_for?(ext_issue.author)).to be_truthy
    end
  end

  describe 'clear_blank_line_code!' do
    it 'clears a blank line code before validation' do
      note = build(:note, line_code: ' ')

      expect { note.valid? }.to change(note, :line_code).to(nil)
    end
  end

  describe '#participants' do
    it 'includes the note author' do
      project = create(:empty_project, :public)
      issue = create(:issue, project: project)
      note = create(:note_on_issue, noteable: issue, project: project)

      expect(note.participants).to include(note.author)
    end
  end

  describe '.find_discussion' do
    let!(:note) { create(:discussion_note_on_merge_request) }
    let!(:note2) { create(:discussion_note_on_merge_request, in_reply_to: note) }
    let(:merge_request) { note.noteable }

    it 'returns a discussion with multiple notes' do
      discussion = merge_request.notes.find_discussion(note.discussion_id)

      expect(discussion).not_to be_nil
      expect(discussion.notes).to match_array([note, note2])
      expect(discussion.first_note.discussion_id).to eq(note.discussion_id)
    end
  end

  describe ".grouped_diff_discussions" do
    let!(:merge_request) { create(:merge_request) }
    let(:project) { merge_request.project }
    let!(:active_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) }
    let!(:active_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, in_reply_to: active_diff_note1) }
    let!(:active_diff_note3) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: active_position2) }
    let!(:outdated_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: outdated_position) }
    let!(:outdated_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, in_reply_to: outdated_diff_note1) }

    let(:active_position2) do
      Gitlab::Diff::Position.new(
        old_path: "files/ruby/popen.rb",
        new_path: "files/ruby/popen.rb",
        old_line: nil,
        new_line: 13,
        diff_refs: project.commit(sample_commit.id).diff_refs
      )
    end

    let(:outdated_position) do
      Gitlab::Diff::Position.new(
        old_path: "files/ruby/popen.rb",
        new_path: "files/ruby/popen.rb",
        old_line: nil,
        new_line: 9,
        diff_refs: project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs
      )
    end

    context 'active diff discussions' do
      subject { merge_request.notes.grouped_diff_discussions }

      it "includes active discussions" do
        discussions = subject.values.flatten

        expect(discussions.count).to eq(2)
        expect(discussions.map(&:id)).to eq([active_diff_note1.discussion_id, active_diff_note3.discussion_id])
        expect(discussions.all?(&:active?)).to be true

        expect(discussions.first.notes).to eq([active_diff_note1, active_diff_note2])
        expect(discussions.last.notes).to eq([active_diff_note3])
      end

      it "doesn't include outdated discussions" do
        expect(subject.values.flatten.map(&:id)).not_to include(outdated_diff_note1.discussion_id)
      end

      it "groups the discussions by line code" do
        expect(subject[active_diff_note1.line_code].first.id).to eq(active_diff_note1.discussion_id)
        expect(subject[active_diff_note3.line_code].first.id).to eq(active_diff_note3.discussion_id)
      end
    end

    context 'diff discussions for older diff refs' do
      subject { merge_request.notes.grouped_diff_discussions(diff_refs) }

      context 'for diff refs a discussion was created at' do
        let(:diff_refs) { active_position2.diff_refs }

        it "includes discussions that were created then" do
          discussions = subject.values.flatten

          expect(discussions.count).to eq(1)

          discussion = discussions.first

          expect(discussion.id).to eq(active_diff_note3.discussion_id)
          expect(discussion.active?).to be true
          expect(discussion.active?(diff_refs)).to be false
          expect(discussion.created_at_diff?(diff_refs)).to be true

          expect(discussion.notes).to eq([active_diff_note3])
        end

        it "groups the discussions by original line code" do
          expect(subject[active_diff_note3.original_line_code].first.id).to eq(active_diff_note3.discussion_id)
        end
      end

      context 'for diff refs a discussion was last active at' do
        let(:diff_refs) { outdated_position.diff_refs }

        it "includes discussions that were last active" do
          discussions = subject.values.flatten

          expect(discussions.count).to eq(1)

          discussion = discussions.first

          expect(discussion.id).to eq(outdated_diff_note1.discussion_id)
          expect(discussion.active?).to be false
          expect(discussion.active?(diff_refs)).to be true
          expect(discussion.created_at_diff?(diff_refs)).to be true

          expect(discussion.notes).to eq([outdated_diff_note1, outdated_diff_note2])
        end

        it "groups the discussions by line code" do
          expect(subject[outdated_diff_note1.line_code].first.id).to eq(outdated_diff_note1.discussion_id)
        end
      end
    end
  end

  describe '#for_personal_snippet?' do
    it 'returns false for a project snippet note' do
      expect(build(:note_on_project_snippet).for_personal_snippet?).to be_falsy
    end

    it 'returns true for a personal snippet note' do
      expect(build(:note_on_personal_snippet).for_personal_snippet?).to be_truthy
    end
  end

  describe '#to_ability_name' do
    it 'returns snippet for a project snippet note' do
      expect(build(:note_on_project_snippet).to_ability_name).to eq('snippet')
    end

    it 'returns personal_snippet for a personal snippet note' do
      expect(build(:note_on_personal_snippet).to_ability_name).to eq('personal_snippet')
    end

    it 'returns merge_request for an MR note' do
      expect(build(:note_on_merge_request).to_ability_name).to eq('merge_request')
    end

    it 'returns issue for an issue note' do
      expect(build(:note_on_issue).to_ability_name).to eq('issue')
    end

    it 'returns issue for a commit note' do
      expect(build(:note_on_commit).to_ability_name).to eq('commit')
    end
  end

  describe '#cache_markdown_field' do
    let(:html) { '
some html
'}

    context 'note for a project snippet' do
      let(:note) { build(:note_on_project_snippet) }

      before do
        expect(Banzai::Renderer).to receive(:cacheless_render_field)
          .with(note, :note, { skip_project_check: false }).and_return(html)

        note.save
      end

      it 'creates a note' do
        expect(note.note_html).to eq(html)
      end
    end

    context 'note for a personal snippet' do
      let(:note) { build(:note_on_personal_snippet) }

      before do
        expect(Banzai::Renderer).to receive(:cacheless_render_field)
          .with(note, :note, { skip_project_check: true }).and_return(html)

        note.save
      end

      it 'creates a note' do
        expect(note.note_html).to eq(html)
      end
    end
  end

  describe '#can_be_discussion_note?' do
    context 'for a note on a merge request' do
      it 'returns true' do
        note = build(:note_on_merge_request)

        expect(note.can_be_discussion_note?).to be_truthy
      end
    end

    context 'for a note on an issue' do
      it 'returns true' do
        note = build(:note_on_issue)

        expect(note.can_be_discussion_note?).to be_truthy
      end
    end

    context 'for a note on a commit' do
      it 'returns true' do
        note = build(:note_on_commit)

        expect(note.can_be_discussion_note?).to be_truthy
      end
    end

    context 'for a note on a snippet' do
      it 'returns true' do
        note = build(:note_on_project_snippet)

        expect(note.can_be_discussion_note?).to be_truthy
      end
    end

    context 'for a diff note on merge request' do
      it 'returns false' do
        note = build(:diff_note_on_merge_request)

        expect(note.can_be_discussion_note?).to be_falsey
      end
    end

    context 'for a diff note on commit' do
      it 'returns false' do
        note = build(:diff_note_on_commit)

        expect(note.can_be_discussion_note?).to be_falsey
      end
    end

    context 'for a discussion note' do
      it 'returns false' do
        note = build(:discussion_note_on_merge_request)

        expect(note.can_be_discussion_note?).to be_falsey
      end
    end
  end

  describe '#discussion_class' do
    let(:note) { build(:note_on_commit) }
    let(:merge_request) { create(:merge_request) }

    context 'when the note is displayed out of context' do
      it 'returns OutOfContextDiscussion' do
        expect(note.discussion_class(merge_request)).to be(OutOfContextDiscussion)
      end
    end

    context 'when the note is displayed in the original context' do
      it 'returns IndividualNoteDiscussion' do
        expect(note.discussion_class(note.noteable)).to be(IndividualNoteDiscussion)
      end
    end
  end

  describe "#discussion_id" do
    let(:note) { create(:note_on_commit) }

    context "when it is newly created" do
      it "has a discussion id" do
        expect(note.discussion_id).not_to be_nil
        expect(note.discussion_id).to match(/\A\h{40}\z/)
      end
    end

    context "when it didn't store a discussion id before" do
      before do
        note.update_column(:discussion_id, nil)
      end

      it "has a discussion id" do
        # The discussion_id is set in `after_initialize`, so `reload` won't work
        reloaded_note = Note.find(note.id)

        expect(reloaded_note.discussion_id).not_to be_nil
        expect(reloaded_note.discussion_id).to match(/\A\h{40}\z/)
      end
    end

    context 'when the note is displayed out of context' do
      let(:merge_request) { create(:merge_request) }

      it 'overrides the discussion id' do
        expect(note.discussion_id(merge_request)).not_to eq(note.discussion_id)
      end
    end
  end

  describe '#to_discussion' do
    subject { create(:discussion_note_on_merge_request) }
    let!(:note2) { create(:discussion_note_on_merge_request, project: subject.project, noteable: subject.noteable, in_reply_to: subject) }

    it "returns a discussion with just this note" do
      discussion = subject.to_discussion

      expect(discussion.id).to eq(subject.discussion_id)
      expect(discussion.notes).to eq([subject])
    end
  end

  describe "#discussion" do
    let!(:note1) { create(:discussion_note_on_merge_request) }
    let!(:note2) { create(:diff_note_on_merge_request, project: note1.project, noteable: note1.noteable) }

    context 'when the note is part of a discussion' do
      subject { create(:discussion_note_on_merge_request, project: note1.project, noteable: note1.noteable, in_reply_to: note1) }

      it "returns the discussion this note is in" do
        discussion = subject.discussion

        expect(discussion.id).to eq(subject.discussion_id)
        expect(discussion.notes).to eq([note1, subject])
      end
    end

    context 'when the note is not part of a discussion' do
      subject { create(:note) }

      it "returns a discussion with just this note" do
        discussion = subject.discussion

        expect(discussion.id).to eq(subject.discussion_id)
        expect(discussion.notes).to eq([subject])
      end
    end
  end

  describe "#part_of_discussion?" do
    context 'for a regular note' do
      let(:note) { build(:note) }

      it 'returns false' do
        expect(note.part_of_discussion?).to be_falsey
      end
    end

    context 'for a diff note' do
      let(:note) { build(:diff_note_on_commit) }

      it 'returns true' do
        expect(note.part_of_discussion?).to be_truthy
      end
    end

    context 'for a discussion note' do
      let(:note) { build(:discussion_note_on_merge_request) }

      it 'returns true' do
        expect(note.part_of_discussion?).to be_truthy
      end
    end
  end

  describe '#in_reply_to?' do
    context 'for a note' do
      context 'when part of a discussion' do
        subject { create(:discussion_note_on_issue) }
        let(:note) { create(:discussion_note_on_issue, in_reply_to: subject) }

        it 'checks if the note is in reply to the other discussion' do
          expect(subject).to receive(:in_reply_to?).with(note).and_call_original
          expect(subject).to receive(:in_reply_to?).with(note.noteable).and_call_original
          expect(subject).to receive(:in_reply_to?).with(note.to_discussion).and_call_original

          subject.in_reply_to?(note)
        end
      end

      context 'when not part of a discussion' do
        subject { create(:note) }
        let(:note) { create(:note, in_reply_to: subject) }

        it 'checks if the note is in reply to the other noteable' do
          expect(subject).to receive(:in_reply_to?).with(note).and_call_original
          expect(subject).to receive(:in_reply_to?).with(note.noteable).and_call_original

          subject.in_reply_to?(note)
        end
      end
    end

    context 'for a discussion' do
      context 'when part of the same discussion' do
        subject { create(:diff_note_on_merge_request) }
        let(:note) { create(:diff_note_on_merge_request, in_reply_to: subject) }

        it 'returns true' do
          expect(subject.in_reply_to?(note.to_discussion)).to be_truthy
        end
      end

      context 'when not part of the same discussion' do
        subject { create(:diff_note_on_merge_request) }
        let(:note) { create(:diff_note_on_merge_request) }

        it 'returns false' do
          expect(subject.in_reply_to?(note.to_discussion)).to be_falsey
        end
      end
    end

    context 'for a noteable' do
      context 'when a comment on the same noteable' do
        subject { create(:note) }
        let(:note) { create(:note, in_reply_to: subject) }

        it 'returns true' do
          expect(subject.in_reply_to?(note.noteable)).to be_truthy
        end
      end

      context 'when not a comment on the same noteable' do
        subject { create(:note) }
        let(:note) { create(:note) }

        it 'returns false' do
          expect(subject.in_reply_to?(note.noteable)).to be_falsey
        end
      end
    end
  end

  describe 'expiring ETag cache' do
    let(:note) { build(:note_on_issue) }

    def expect_expiration(note)
      expect_any_instance_of(Gitlab::EtagCaching::Store)
        .to receive(:touch)
        .with("/#{note.project.namespace.to_param}/#{note.project.to_param}/noteable/issue/#{note.noteable.id}/notes")
    end

    it "expires cache for note's issue when note is saved" do
      expect_expiration(note)

      note.save!
    end

    it "expires cache for note's issue when note is destroyed" do
      expect_expiration(note)

      note.destroy!
    end
  end
end


text:
#ifndef CTREEMODEL_H
#define CTREEMODEL_H

#include "ctreeitem.h"

#include <QAbstractItemModel>
#include <QMimeData>
#include <QModelIndex>
#include <QVariant>

class CTreeModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    CTreeModel(QObject *parent = 0);
    ~CTreeModel();

    QVariant data(const QModelIndex &index, int role) const;
    //Qt::ItemFlags flags(const QModelIndex &index) const;
    QVariant headerData(int section, Qt::Orientation orientation,
                         int role = Qt::DisplayRole) const;
    QModelIndex index(int row, int column,
                       const QModelIndex &parent = QModelIndex()) const;
    QModelIndex parent(const QModelIndex &index) const;
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    bool hasChildren(const QModelIndex &parent = QModelIndex()) const;

    QString fullPath(const QModelIndex &index) const;
    QString volume(const QModelIndex &index) const;

    /*Qt::DropActions supportedDropActions() const;
    QStringList mimeTypes() const;
    QMimeData* mimeData(const QModelIndexList &indexes) const;
    bool dropMimeData(const QMimeData *data,
     Qt::DropAction action, int row, int column, const QModelIndex &parent);*/

public slots:
    void expanded(const QModelIndex &index);
    void collapsed(const QModelIndex &index);

private slots:
    void itemRefreshed();
    void rootRefreshed();

private:
    CTreeItem *rootItem;

    CTreeItem* createRoot();
};

#endif // CTREEMODEL_H


text:
// flow-typed signature: 505ee5d92e95c75c4d6aaab8085be194
// flow-typed version: <<STUB>>/setimmediate_v~1.0.5/flow_v0.121.0

/**
 * This is an autogenerated libdef stub for:
 *
 *   'setimmediate'
 *
 * Fill this stub out by replacing all the `any` types.
 *
 * Once filled out, we encourage you to share your work with the
 * community by sending a pull request to:
 * https://github.com/flowtype/flow-typed
 */

declare module 'setimmediate' {
  declare module.exports: any;
}

/**
 * We include stubs for each file inside this npm package in case you need to
 * require those files directly. Feel free to delete any files that aren't
 * needed.
 */
declare module 'setimmediate/setImmediate' {
  declare module.exports: any;
}

// Filename aliases
declare module 'setimmediate/setImmediate.js' {
  declare module.exports: $Exports<'setimmediate/setImmediate'>;
}


text:
package com.azure.iot.modelsrepository;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

class TestsAssetsHelpers {
    public static String readResourceFile(String filePathFromResources) throws IOException {
        String pathToResources = System.getProperty("user.dir") + "/src/test/resources/" + filePathFromResources;

        return new String(Files.readAllBytes(Paths.get(pathToResources)));
    }
}


text:
package org.tinymediamanager.ui.movies.actions;

import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import javax.swing.AbstractAction;

import org.tinymediamanager.core.ImageCache;
import org.tinymediamanager.core.movie.entities.Movie;
import org.tinymediamanager.ui.MainWindow;
import org.tinymediamanager.ui.UTF8Control;
import org.tinymediamanager.ui.movies.MovieUIModule;

/**
 * MovieClearImageCacheAction - clear image cache for selected movies
 *
 * @author Manuel Laggner
 */
public class MovieClearImageCacheAction extends AbstractAction {
  private static final long           serialVersionUID = -5089957097690621345L;
  private static final ResourceBundle BUNDLE           = ResourceBundle.getBundle("messages", new UTF8Control()); //$NON-NLS-1$

  public MovieClearImageCacheAction() {
    putValue(NAME, BUNDLE.getString("movie.clearimagecache")); //$NON-NLS-1$
    putValue(LARGE_ICON_KEY, "");
  }

  /*
   * (non-Javadoc)
   *
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  @Override
  public void actionPerformed(ActionEvent e) {
    List<Movie> selectedMovies = new ArrayList<Movie>(MovieUIModule.getInstance().getSelectionModel().getSelectedMovies());

    // get data of all files within all selected movies
    MainWindow.getActiveInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    for (Movie movie : selectedMovies) {
      ImageCache.clearImageCacheForMediaEntity(movie);
    }
    MainWindow.getActiveInstance().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  }
}